Skip to content

Instantly share code, notes, and snippets.

@nytr0gen
nytr0gen / Preferences.sublime-settings
Last active May 12, 2016 11:52
Sublime Text Preferences
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"codeintel_syntax_map":
{
"JavaScript": "Node.js"
},
"color_scheme": "Packages/User/SublimeLinter/Monokai - Spacegray (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
@nytr0gen
nytr0gen / uniqueFiles.go
Created May 12, 2016 11:51
sort unique all files in golang
import (
"errors"
"io/ioutil"
"os"
"os/exec"
)
func UniqueFiles(files ...string) (err error) {
if len(files) == 0 {
return errors.New("no files provided")
@nytr0gen
nytr0gen / encodeNP.js
Last active June 7, 2016 15:08
Encode non-printable characters as hex
var encodeNP = function(s){
var hex, c;
var result = '';
for (var i = 0; i < s.length; i++) {
c = s.charCodeAt(i);
if (c >= 32 && c <= 126) {
result += String.fromCharCode(c);
} else {
hex = c.toString(16);
result += '\\x' + ('000'+hex).slice(-4);
for i in `seq 2 30`; do
say --progress -r340 -vIoana $i' elefanți se legănau pe o pânză de păianjen, și pentru că, nu se rupea, au mai chemat un elefant';
done
for (var i = 0; i < 100; i++) {
setTimeout(function(i) {
var text = '/remind me invata python boss in ' + (2*i) + ' minutes';
TS.client.ui.onSubmit(text);
console.log(text);
}.bind(this, i), i * 500);
}
@nytr0gen
nytr0gen / machinery_add_task.js
Created March 21, 2017 17:41
machinery add task pseudocode-ish
id = video_id
task_name = "task_" + generateUUID()
task_status = {
"TaskUUID": task_name,
"State": "PENDING",
"Result": null,
"Error": ""
}
task = {
"UUID": task_name,
def bin_sqrt(v):
lo, hi = 0, v
while (hi - lo) > 1:
mid = (hi + lo) // 2
sqrmid = mid * mid
if sqrmid < v:
lo = mid
elif sqrmid > v:
hi = mid
else:
# facebook has a weird format for naming images you download
# it should be timestamp first so you can sort them
# but no, they have a weird id first
# something like {rnd}_{timestamp}_{rnd}_o.jpg
ls *.jpg | awk -F_ '{print $2}' | xargs -I{} bash -c 'mv *{}*.jpg {}.jpg'
@nytr0gen
nytr0gen / settings.js
Last active December 5, 2017 18:33
VSCode Settings
{
"editor.wordWrap": "on",
"editor.formatOnPaste": false,
"docker.showExplorer": false,
// JS specific
"eslint.enable": false,
// Python specific
"python.venvPath": "${workspaceRoot}/.venv",
@nytr0gen
nytr0gen / draw.py
Created February 3, 2020 10:54
Drawing tool for HackTM quals challenge
# https://github.com/nytr0gen
import requests
import PIL
import marshal
import os
import time
from PIL import Image
from multiprocessing import Pool