Skip to content

Instantly share code, notes, and snippets.

View AndyHoang's full-sized avatar

Andy Hoang AndyHoang

View GitHub Profile
@AndyHoang
AndyHoang / map_for_object.js
Created February 18, 2016 10:22
map for object
Object.defineProperty(Object.prototype, 'map', {
value: function(f, ctx) {
ctx = ctx || this;
var self = this, result = {};
Object.keys(self).forEach(function(k) {
result[k] = f.call(ctx, self[k], k, self);
});
return result;
}
});
@AndyHoang
AndyHoang / gist:d35b3a70fe41fa20c1326049cd62f7bb
Last active January 16, 2017 02:25 — forked from j3j5/gist:8b3e48ccad746b90a54a
Adyen Test Card Numbers
Adyen Test Card Numbers
These cards are only valid on our TEST system and they will never involve any actual transaction or transfer of funds. The TEST card numbers will not work on the Adyen LIVE Platform.
For all cards use the following expiration and CVV2/CVC2/or CID for Amex.
For all cards:
Expiration Dates CVV2 / CVC3 CID (American Express)
@AndyHoang
AndyHoang / pre_next.py
Created June 2, 2017 02:40
pre next from generator
#https://stackoverflow.com/questions/1011938/python-previous-and-next-values-inside-a-loop
from itertools import tee, islice, chain, izip
def previous_and_next(some_iterable):
prevs, items, nexts = tee(some_iterable, 3)
prevs = chain([None], prevs)
nexts = chain(islice(nexts, 1, None), [None])
return izip(prevs, items, nexts)
from __future__ import division
from itertools import izip, count
from numpy import loadtxt, ones, convolve
import numpy as np
import pandas as pd
import collections
from random import randint
data = loadtxt("sunspots.txt", float)
@AndyHoang
AndyHoang / ra2_yuri_wine
Created July 23, 2017 08:12 — forked from nicklevett/ra2_yuri_wine
RA2/Yuri's Revenge on Wine on Mac OS X
Prerequisites (this is what I use, your mileage may vary):
Mac OS X 10.10.4 running on iMac13,2
XQuartz (http://xquartz.macosforge.org)
PlayOnMac 4.2.8 (https://www.playonmac.com) - N.B. PlayOnLinux available
Wine 1.6.2 (downloaded in PlayOnMac)
The First Decade (TFD) DVD (Red Alert 2 and Yuri's Revenge)
TFD v1.03 revision 4 patch (http://www.cncnz.com/hosted-projects/command-patch/the-first-decade-unofficial-patch/)
Updates to latest versions of RA2 and Yuri plus NO-CD, TCP (network play) patch and other goodies
Install PlayOnMac
@AndyHoang
AndyHoang / peerflix-hook.lua
Last active June 3, 2018 04:24 — forked from ekisu/peerflix-hook.lua
A Lua user script for mpv that allows playing of magnet links, similar to the youtube-dl hook.
local utils = require 'mp.utils'
local msg = require 'mp.msg'
-- OPTIONS
local keep_file_after_streaming = false
local peerflix = {
path = "peerflix",
searched = false
}
@AndyHoang
AndyHoang / install-ripgrep-on-ubuntu.sh
Created September 6, 2019 03:55 — forked from kostaz/install-ripgrep-on-ubuntu.sh
Install ripgrep on Ubuntu
#!/bin/bash
[[ $UID == 0 ]] || { echo "run as sudo to install"; exit 1; }
REPO="https://github.com/BurntSushi/ripgrep/releases/download/"
RG_LATEST=$(curl -sSL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | jq --raw-output .tag_name)
RELEASE="${RG_LATEST}/ripgrep-${RG_LATEST}-x86_64-unknown-linux-musl.tar.gz"
TMPDIR=$(mktemp -d)
cd $TMPDIR
wget -O - ${REPO}${RELEASE} | tar zxf - --strip-component=1
>>> CarrierMasterData.objects.filter(id=81) // my caching models
('GET', '{pp_data_io}q:8f753017faabca24a400ce1477b2d689')
('EVALSHA', 'f6b93ec749d56aefa37c49bbc5e7a6eedd0d4ec3', 3, '{pp_data_io}', '{pp_data_io}q:8f753017faabca24a400ce1477b2d689', '', b'\x80\x04\x95\xf9\x07\x00\x00\x00\x00\x00\x00]\x94\x8c\x15django.db.models.base\x94\x8c\x0emodel_unpickle\x94\x93\x94\x8c\x03api\x94\x8c\x11CarrierMasterData\x94\x86\x94\x85\x94R\x94}\x94(\x8c\x06_state\x94h\x01\x8c\nModelState\x94\x93\x94)\x81\x94}\x94(\x8c\x06adding\x94\x89\x8c\x02db\x94\x8c\x07default\x94ub\x8c\x02id\x94KQ\x8c\x04name\x94\x8c\rDHL eCommerce\x94\x8c\tslug_name\x94\x8c\x0fdhl-global-mail\x94\x8c\ncarrier_id\x94\x8c\x06dhleco\x94\x8c\x0caftership_id\x94]\x94(\x8c\x0fdhl-global-mail\x94\x8c\x14dhl-global-mail-asia\x94e\x8c\rcarrier_17_id\x94]\x94(\x8c\x0507048\x94\x8c\x0507047\x94e\x8c\x15carrier_countries_iso\x94]\x94\x8c\x11carrier_countries\x94]\x94\x8c\x10carrier_language\x94\x8c\x02en\x94\x8c\x10carrier_cs_phone\x94\x8c\x0f+1 317 554 5191\x
class CacheopsRedisCluster(StrictRedisCluster, CacheopsRedis):
get = handle_connection_failure(StrictRedisCluster.get)
def __init__(self, *args, **kwargs):
init_slot_cache = kwargs.get('init_slot_cache', True)
super(CacheopsRedisCluster, self).__init__(*args, **kwargs)
# lazy initialize nodes, so that if redis is downed before starting django, everything still fine
if not init_slot_cache:
self.refresh_table_asap = True
@AndyHoang
AndyHoang / run_grim_dawn.sh
Created November 24, 2019 04:19
grim dawn sh linux internals
#!/bin/bash
#Run game or given command in environment
# export DXVK_HUD=fps
cd "/home/andyhoang/mnt/SteamLibrary/steamapps/common/Grim Dawn"
# make sure grim internals located in Grim Dawn folder, not inside x64
DEF_CMD=("/home/andyhoang/mnt/SteamLibrary/steamapps/common/Grim Dawn/GrimInternals64.exe")
PATH="/home/andyhoang/.local/share/Steam/steamapps/common/Proton 4.11/dist/bin/:/home/andyhoang/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/bin:/home/andyhoang/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/bin:/home/andyhoang/.local/share/Steam/ubuntu12_32/steam-runtime/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" \
TERM="xterm" \