Skip to content

Instantly share code, notes, and snippets.

View alfasin's full-sized avatar
🖖
He bag production, he got walrus gumboot

Nir Alfasi alfasin

🖖
He bag production, he got walrus gumboot
View GitHub Profile
@alfasin
alfasin / xor.py
Created October 24, 2018 02:56 — forked from revolunet/xor.py
Simple python XOR encrypt/decrypt
#
# NB : this is not secure
# from http://code.activestate.com/recipes/266586-simple-xor-keyword-encryption/
# added base64 encoding for simple querystring :)
#
def xor_crypt_string(data, key='awesomepassword', encode=False, decode=False):
from itertools import izip, cycle
import base64
if decode:
@alfasin
alfasin / uniq.js
Created June 1, 2018 22:38 — forked from telekosmos/uniq.js
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
@alfasin
alfasin / hashcat_macos.sh
Created April 21, 2018 04:18 — forked from chadmayfield/hashcat_macos.sh
Install Hashcat on macOS
#!/bin/bash
git clone https://github.com/hashcat/hashcat.git
mkdir -p hashcat/deps
git clone https://github.com/KhronosGroup/OpenCL-Headers.git hashcat/deps/OpenCL
cd hashcat/ && make
./hashcat --version
./hashcat -b -D 1,2
./example0.sh
id email username last_name created_at first_name hashed_password
1 [email protected] jmonroe99 Munroe NULL Jim $2y$11$Co5fHvH5Lgk2Zu0iHR46BO6fnqQt1pUljPbZOhk7bTU6hQFhjBJG.
2 [email protected] lbtables Tables 2016-06-03 19:33:54 Bobby $2y$10$I.Jwfc8R3xaFwlAlPn5U3OLAQXrE0c2fakN8rR4j2TW0gRVMd6U6a
3 [email protected] pperson Person 2017-01-01 02:50:26 Pat $2y$11$FHZQn1eWZ3mbn11evb3CSeM20LCsJZI8yP9wS/UsOI6VWnx.7mKDa
@alfasin
alfasin / unittest.js
Created December 16, 2017 09:25
An example of how to use `tap` to create unit-tests
var sum = function (a, b, f) { return f(null, a + b) }
var test = require('tap').test;
test('sums 1 and 2', function (t) {
sum(1, 2, function (err, result) {
t.notOk(err, 'no error');
t.equal(result, 3, '1 + 2 should be equal to 3');
t.end();
});
@alfasin
alfasin / twitter.js
Created December 16, 2017 09:17
Drink from the firehose and filter the tweets by 'statuses/filter'
var Twitter = require('twitter')
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'mytweet'});
log.info('hi');
var client = new Twitter({
consumer_key: '***************',
consumer_secret: '***************',
access_token_key: '***************',
@alfasin
alfasin / benchmark.js
Created December 16, 2017 09:11
An example of how to benchmark js code. In this example we compare 3 ways to remove elements from an array.
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('shift', function() {
let arr = [1,2,3,4,5,6,7,8,9,0]
for (let i in arr) {
arr.shift()
}
})
.add('slice', function() {
@alfasin
alfasin / isDate.js
Created December 4, 2017 06:04
Stolen from: http://jsfiddle.net/niklasvh/xfrLm/ a neat way to verify that a given date (in string format) is valid
/*
* Takes input as date-dtring in the format of mm/dd/yyyy and verifies that it's a valid date
* by creating a date object out of it and comparing the year/month/day to the given ones
*/
function isDate(date) {
var objDate, // date object initialized from the date string
mSeconds, // date in milliseconds
day, // day
month, // month
year; // year
#!/apps/python/bin/python
import logging
import gspread
from creds import API_ACCESS_KEY, get_client_email, get_private_key
logger = logging.getLogger('nflx.' + __name__)
headers = {
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
'Content-type': 'application/json',
public static final Map<String, String> STATE_MAP;
static {
STATE_MAP = new HashMap<String, String>();
STATE_MAP.put("AL", "Alabama");
STATE_MAP.put("AK", "Alaska");
STATE_MAP.put("AB", "Alberta");
STATE_MAP.put("AZ", "Arizona");
STATE_MAP.put("AR", "Arkansas");
STATE_MAP.put("BC", "British Columbia");
STATE_MAP.put("CA", "California");