This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import sqlite3 | |
import json | |
import datetime | |
db = "tmp.sqlite" | |
def create_db(): | |
if os.path.isfile(db): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.antelle; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
public class Program implements java.util.Comparator<java.lang.String> { | |
public static void main(String [] args) { | |
happyDebugging(); | |
System.out.format("compare result: %s", "abc".compareToIgnoreCase("trololo")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "{} {}".format("a", "b") => "a b" | |
// "{1} {0}".format("a", "b") => "b a" | |
// "{foo} {bar}".format({ foo: "a", bar: "b" }) => "a b" | |
String.prototype.format = function() { | |
var args = arguments; | |
var argNum = 0; | |
return this.replace(/\{(\w*)\}/gi, function(match) { | |
var curArgNum, prop = null; | |
if (match == "{}") { | |
curArgNum = argNum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.blinking { | |
animation: blink 1s steps(2, start) infinite; | |
-webkit-animation: blink 1s steps(2, start) infinite; | |
} | |
@keyframes blink { to { visibility: hidden; } } | |
@-webkit-keyframes blink { to { visibility: hidden; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modified version of http://www.sitepoint.com/sass-theming-neverending-story/ | |
// allows to write themified code without breaking modular project structure | |
// only one global variable | |
// Theme definitions | |
$themes: ( | |
unicorn: (primary: hotpink, secondary: pink), | |
dragon: (primary: firebrick, secondary: red) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in *.JPG *.jpg; do convert "$f" -resize "1200x1200>" -quality 85 -verbose "$f"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static function OnBeforeRequest(oSession: Session) { | |
if (oSession.RequestMethod == 'GET' && oSession.PathAndQuery.IndexOf('part_of_your_url') > 0) { | |
oSession.utilCreateResponseAndBypassServer(); | |
oSession.oResponse.headers.HTTPResponseCode = 401; | |
oSession.oResponse.headers.HTTPResponseStatus = '401 Not Authorized'; | |
oSession.oResponse.headers['Access-Control-Allow-Origin'] = '*'; | |
oSession.utilSetResponseBody('response_body'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
U+2060 foobar WORD JOINER | |
U+2061 foobar FUNCTION APPLICATION | |
U+2062 foobar INVISIBLE TIMES | |
U+2063 foobar INVISIBLE SEPARATOR | |
U+180E foobar MONGOLIAN VOWEL SEPARATOR | |
U+200B foobar ZERO WIDTH SPACE | |
U+200C foobar ZERO WIDTH NON-JOINER | |
U+200D foobar ZERO WIDTH JOINER | |
U+FEFF foobar ZERO WIDTH NO-BREAK SPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numbers = '1 2 3'.split(' ').map(n => +n); | |
getCombinations([], numbers, x => console.log('C', x.join(' '))); | |
getPermutations([], numbers, x => console.log('P', x.join(' '))); | |
function getCombinations(first, chars, cb) { | |
for (var i = 0; i < chars.length; i++) { | |
cb(first.concat(chars[i])); | |
getCombinations(first.concat(chars[i]), chars.slice(i + 1), cb); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function escape(str) { | |
return str.replace(/[\n\r\\\'\u2028\u2029]/g, ch => { | |
if (ch === '\n') { return '\\n'; } | |
else if (ch === '\r') { return '\\r'; } | |
else if (ch === '\\') { return '\\\\'; } | |
else if (ch === '\'') { return '\\\''; } | |
else if (ch === '\u2028') { return '\\u2028'; } | |
else if (ch === '\u2029') { return '\\u2029'; } | |
else throw 'Bad char'; | |
}); |
OlderNewer