Skip to content

Instantly share code, notes, and snippets.

View clayrisser's full-sized avatar
🤓
coding

Clay Risser clayrisser

🤓
coding
View GitHub Profile
@clayrisser
clayrisser / currentAwardsConfig.js
Last active June 12, 2017 22:59
ProManager Example Awards Config
'use-strict';
module.exports = {
doLogin: {
/**
* Adds 5 coins every time a user logs into their account.
*/
coins: 5,
/**
* Adds the 'some-badge' and 'some-other-badge' the first
#
# Script by Leigh Purdie
#
# 1) Install a Ubuntu system, and remove packages according to your
# requirements using synaptic.
# Don't install any new packages that are NOT available from the CD,
# at this stage, unless you include the packages in an 'extras' directory.
#
# 2) dpkg -l > PackageList
# Copy this file to $BASEDIR/source on your build server.
@clayrisser
clayrisser / .dockerignore
Created April 28, 2017 13:53
Docker tutorial
node_modules
var Promise = require('bluebird');
var callbackHellTimeout = function(cb, time) {
setTimeout(function() {
cb();
}, time);
};
var promiseTimeout = function(time) {
return new Promise(function(resolve, reject) {
@clayrisser
clayrisser / fire_gun.py
Last active January 30, 2017 09:18
Very simple python asynchronous twisted example
from twisted.internet import reactor
def main():
reactor.addSystemEventTrigger('during', 'bang', bangHandler) # 3 listening for bang event - when heard, bangHandler() will be called
loadingGun() # 4 loadingGun() called
def loadingGun():
print('Loading gun . . .')
reactor.callLater(5, aimingGun) # 5 after 5 seconds aimingGun() called
@clayrisser
clayrisser / combinations.js
Last active January 28, 2017 23:55
Find all combinations of a given string in JavaScript
var _ = require('lodash');
console.log(combinations('abc'));
function combinations(chars) {
return getCombinations(chars.length, chars);
}
function getCombinations(count, chars, word) {
var combinations = [];
@clayrisser
clayrisser / cookies.js
Last active January 21, 2017 22:43
VanillaJS Cookie Functions
var cookie = {
set: function(name, value, seconds) {
setCookie(name, value, seconds);
},
clear: function(name, value, seconds) {
setCookie(name, null, -1);
},
clearAll: function() {
#!/bin/python3
import os
os.system('cd ~/Android/Sdk/tools')
AVDs = [file.split('.')[0] for file in os.listdir(os.path.expanduser('~/.android/avd/')) if file.split('.')[len(file.split('.'))-1] == 'ini']
i = 0
for avd in AVDs:
i += 1
@clayrisser
clayrisser / getMe.py
Last active December 21, 2016 07:56
Get own docker container from docker-py
import socket
import docker
client = docker.DockerClient(base_url='unix://var/run/docker.sock')
def getMe():
ip = socket.gethostbyname(socket.gethostname())
containers = client.containers.list()
for container in containers:
containerIP = container.attrs['NetworkSettings']['Networks']['bridge']['IPAddress']
if (ip == containerIP):
@clayrisser
clayrisser / createPromise.js
Last active March 5, 2017 09:39
How to create a Promise
var Promise = require('bluebird');
var callbackHellTimeout = function(cb, time) {
setTimeout(function() {
cb();
}, time);
};
var promiseTimeout = function(time) {
return new Promise(function(resolve, reject) {