Posts

c# - How to do Recursice Funciton Return List<>? -

i trying playlist on youtube , using json http request. youtube playlist api supports max 50 results want make recursive funciton , funciton should return list. private async task<list<classes.playlist>> getplaylist(string id, string pagetoken = null) { string jsontext = await x.getjson(id, pagetoken); list<classes.playlist> list = new list<classes.playlist>(); if (jsontext == null) { return null; } else { jobject jsonobj = jobject.parse(jsontext); foreach (var item in jsonobj["items"]) { list.add(new classes.playlist { image = (string)item["snippet"]["thumbnails"]["default"]["url"], title = (string)item["snippet"]["title"], videoid = (string)item["snippet"]["resourceid...

wordpress - PHP and Shortcode Combination -

on website display social locker wordpress plugin around custom field. <?php echo do_shortcode('[sociallocker]'.$to_lock.'[/sociallocker]');?> here custom field <?php the_field('link'); ?> social locker requires open , close shortcode: [sociallocker id="16619"] [/sociallocker] the following not work correctly: <?php echo do_shortcode('[sociallocker id="16619"]'); ?> <?php the_field('link'); ?> <?php echo do_shortcode('[/sociallocker]'); ?> the function do_shortcode accept single shortcode, can't pass parts of shortcode (open tag, content, closing tag) separately. in case there opening , closing shortcode, should call following. <?php echo do_shortcode( '[s_tag]' . $content . '[/s_tag]' ); ?> so, you've update following lines <?php echo do_shortcode('[sociallocker id="16619"]'); ?> <?php the_field(...

sml - How to have more than one type in ML? -

is possible in ml allow variable in ml have more 1 type? for instance, if want node in tree int or string. node of int * string i tried results in tuple type of (int, string). don't want tuple, either int or string. allowed? as pointed out in comment, feature you're looking union types. believe syntax them in sml is: datatype node = intnode of int | stringnode of string

encoding - Javascript function to replace iso-8859-2 characters with utf8 characters -

i'm gathering data websites nodejs, request , cheerio, 1 site has iso-8859-2 charset , characters not appear correctly. i tried use iconv-lite, iconv.encode(str, "utf-8") or iconv.decode(str, "utf-8") gave me same output or hexadecimal value. plan create function replaces hungarian iso-8859-2 characters uft8 characters (since there few characters , of them has exact match except 2 has relative match). the first issue don't know how grab iso-8859-2 values. gave sample string contains (but not all!) values, i'm sure there's better solution. idea put iso-8859-2 charachters , utf-8 characters in array , use replace method change values. var teststring = "besz�ll�t�"; var = teststring.substring(4, 7); teststring = teststring.replace(a, "\xe1"); var = teststring.substring(7, 10); teststring = teststring.replace(i, "\xed"); var o = teststring.substring(9, 12) teststring = teststring.replace(o, "\xf3"); ...

django - Default image avatar depending on gender -

i create kind of profiles default avatars. gender_choices = ( ('m', 'male'), ('f', 'female'), ) class someone(models.model): name = models.charfield(max_length=120) gender = models.charfield(max_length=1, choices=gender_choices) image = models.imagefield(upload_to='avatars', default=someone_avatar) i'm trying write function returns path folder jpg. def someone_avatar(instance): gender = instance.gender if gender == 'male': avatar = 'avatars/m.jpg' else: avatar = 'avatars/f.jpg' return avatar obviously doesn't work, give me advise how solve it? maybe should overwrite save method? thx. edited ok, tried post_save does't work well: def set_avatar(instance): avatar = instance.image gender = instance.gender if gender == 'male': avatar = 'persons/m.jpg' else: avatar = 'persons/f.jpg' retur...

android - I want to add a progress dialog -

i want add progress dialog. want add error internet connection . how do. happy if write clearly. it's mine fragment activity turkish: eğer bizimkilerden biri okuyorsa şöyle diyim hani webview hazırlandığında yuvarlak bişey dönüyor ya ondan olsun istiyorum birde internet yoksa bağlantı yok hatası istiyorum my xml <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.kamubilgi.kamu_bilgi.ekran2"> <!-- todo: update blank fragment layout --> <webview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/webview3" /> </framelayout> my fregment activity package com.kamubilgi.kamu_bilgi; import android.os.bundle; import andr...

Exporting logs from Snort to Syslog-ng to Redis -

i using snort 2.9.3 , export logs syslog-ng, , syslog-ng redis database. found plugin: syslog-ng-mod-redis however, include this? how can confirm logs produced snort can read syslog-ng? i using ubuntu 16.04 if install plugin, loaded automatically. can check following command: syslog-ng -v on ubuntu syslog-ng confined apparmor. check security logs, , if see access denied, add rule apparmor able read snort logs.