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
sudo killall -HUP mDNSResponder |
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
const http = require('http'); | |
const path = require('path'); | |
const fs = require('fs'); | |
const port = 8080; | |
const server = http.createServer((req, resp) => { | |
const filePathPart = req.url.substr(1) || 'index.html'; | |
const filePath = path.resolve(__dirname, filePathPart); | |
if (!filePath.startsWith(__dirname)) { |
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'; | |
}); |
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
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
// "{} {}".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
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
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
// 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) | |
); |
NewerOlder