View slug.js
function stringToSlug(str) {
// remove accents
var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñç",
to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouunc";
for (var i=0, l=from.length ; i < l ; i++) {
str = str.replace(RegExp(from[i], "gi"), to[i]);
str = str.toLowerCase()
View ribbon.css
width: 300px;
height: 300px;
background: #FFF;
.ribbon-container .ribbon{
View decorator don
__author__ = 'bluzky'
def name_decorator(f):
def wrapper(ten):
chuoi_moi = "Ten tui la %s" % ten
return f(chuoi_moi)
return wrapper
# su dung decorator
View Change listview style.xml
<!--1. create a style with a control template
2. create trigger in style to overide default behaviour
3. apply style to listview
<Grid x:Name="LayoutRoot">
<Style x:Key="listBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Template">
View string_convert.cpp
wstring utf8_to_utf16(string utf8)
std::vector<unsigned long> unicode;
size_t i = 0;
while (i < utf8.size())
unsigned long uni;
size_t todo;
bool error = false;
unsigned char ch = utf8[i++];
View Disable wpf webbrowser script error.cs
[ComImport, Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IOleServiceProvider
int QueryService([In] ref Guid guidService, [In] ref Guid riid, [MarshalAs(UnmanagedType.IDispatch)] out object ppvObject);
public static void SetSilent(WebBrowser browser, bool silent)
if (browser == null)
View curl option.txt
Pass a pointer to a function that matches the following prototype: size_t function( char *ptr, size_t size, size_t nmemb, void *userdata); This function gets called by libcurl as soon as there is data received that needs to be saved. The size of the data pointed to by ptr is size multiplied with nmemb, it will not be zero terminated. Return the number of bytes actually taken care of. If that amount differs from the amount passed to your function, it'll signal an error to the library. This will abort the transfer and return CURLE_WRITE_ERROR.
Set the userdata argument with the CURLOPT_WRITEDATA option.
The callback function will be passed as much data as possible in all invokes, but you cannot possibly make any assumptions. It may be one byte, it may be thousands. The maximum amount of body data that can be passed to the write callback is defined in the curl.h header file: CURL_MAX_WRITE_SIZE (the usual default is 16K). If you however have CURLOPT_HEADER set, which sends header data to


"Return" comes through to your dialog as the "OnOK" callback. If you're not handling the "OnOK" in your code (like you don't have an "OK" button displayed), you can simply provide an OnOK() handler that does nothing (do not call CDialog::OnOK())

void MyDialog::OnOK()
// I have no OK button so don't let default <cr> close the app
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console