Skip to content

Instantly share code, notes, and snippets.

View seveibar's full-sized avatar
💭
twitter dms or mentions to get my attenion!

Severin Ibarluzea seveibar

💭
twitter dms or mentions to get my attenion!
View GitHub Profile
@seveibar
seveibar / serial-resolve.js
Created April 14, 2017 23:37
Resolve promises serially, with a given number in parallel
// @flow
export const serialResolve = (functionsReturningPromises: Array<() => Promise<any>>, parallelTasks: number) => new Promise((resolve, reject) => {
let tasksStarted = 0;
// Create empty results array
const results = Array.from(functionsReturningPromises, () => null);
const totalFunctions = functionsReturningPromises.length;
// When a promise completes, set the correct results index and start any additional tasks
let completedPromises = 0;
Privacy Policy of Ultimate Miner
In order to receive information about your Personal Data, the purposes and the parties the Data is shared with, contact the Owner.
Data Controller and Owner
Types of Data collected
The owner does not provide a list of Personal Data types collected.
Other Personal Data collected may be described in other sections of this privacy policy or by dedicated explanation text contextually with the Data collection.
The Personal Data may be freely provided by the User, or collected automatically when using this Application.
Any use of Cookies - or of other tracking tools - by this Application or by the owners of third party services used by this Application, unless stated otherwise, serves to identify Users and remember their preferences, for the sole purpose of providing the service required by the User.
Failure to provide certain Personal Data may make it impossible for this Application to provide its services.
Users are responsible for any Personal Data of third parties obtained, publ
@seveibar
seveibar / docker-garbage-bridge-network-clean.bash
Created January 21, 2017 13:27
Cleans garbage bridge ips docker leaves around
#!/bin/bash
ifconfig | grep "br-" | sed s/:.*// | xargs -I interface ip link set interface down
brctl show | grep "br-" | sed s/\s*8000.*// | xargs -I interface brctl delbr interface
async function add(x:number,y:number):Promise<number>{
return x + y
}
const a = [1,2,3,4,5]
function PARALLEL(){
return Promise.all(a.map((v) => add(v,1)))
}
@seveibar
seveibar / groll.sh
Created November 27, 2016 23:23
If you prefer to always work in a detached head state, this will allow you to quickly do a PR and return to master w/o creating branches
#!/bin/bash
git checkout -b $1
git push origin $1
hub pull-request
read -p "back to master? <y/N> " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
git fetch
git checkout origin/master
/*
Hot Session Middleware
A hot session only exists on the server, we track it and expire it. It is cookie-less,
however the client needs to keep sending their token. It's basically a cookie without
cookies.
TODO This is not distributed, it can only be run on a single server, and a server restart
will cause all sessions to disappear.
@seveibar
seveibar / download-organizer.py
Last active May 16, 2016 02:26
Organizes downloads in your downloads directory by time. Puts files into "_hours", "_days", "_weeks"
#!/usr/bin/python
import os.path as path,os,json, time
# Get path to temporary files for scripts directory
tmpDir = path.join(path.dirname(path.realpath(__file__)), "tmp")
class File:
def __init__(self, name, path, creationTime):
self.name = name
self.path = path
@seveibar
seveibar / filetype_sorter.py
Created March 3, 2016 01:16
Creates directory with filetypes for all files in specified directory
import shutil
import os
from os.path import join
import time
import sys
"""
USAGE
python filetype_sorter.py <target directory>
"""
directory = sys.argv[1]
# This script is for automatically labeling all the images in a directory with their
# names (for lab reports, technical documents etc.). Uses ImageMagick's convert command.
# Currently windows specific, but it should be easy to make compatible with linux
# This may also be possible as a one-liner with image magick.
import os
import os.path
try: os.system('rmdir labeled /s /q')
except: pass
@seveibar
seveibar / i3-rename-workspace.py
Created June 29, 2015 18:13
i3-rename-workspace
import subprocess
import json
import sys
workspaces = json.loads(subprocess.check_output("i3-msg -t get_workspaces", shell=True));
activeWorkspaceNum = None
activeWorkspaceName = None
for workspace in workspaces:
if workspace["visible"]:
activeWorkspaceNum = workspace['num']