Skip to content

Instantly share code, notes, and snippets.

View kageurufu's full-sized avatar
🏠
Working from home

Frank Tackitt kageurufu

🏠
Working from home
View GitHub Profile
@kageurufu
kageurufu / devdating.js
Created June 3, 2015 16:24
devdating.net solution
return map.map(function(column_str) {
var col = column_str.split(""),
y = col.length;
while(y >= 0) {
if (col[y] == 'o' && col[y + 1] === '.') {
col[y + 1] = col[y];
col[y] = '.';
y++;
} else y--;
@kageurufu
kageurufu / __init__.py
Created May 21, 2015 19:17
Example of loading large data in memory
from flask import Flask
app = Flask(__name__)
from . import views
import time
from threading import Thread, Event
import Queue
from flask import Flask, request
class LoopThread(Thread):
def __init__(self, stop_event, interrupt_queue):
self.stop_event = stop_event
self.interrupt_queue = interrupt_queue
Thread.__init__(self)
// Problem 1
function forSum(arr) {
var sum = 0, i;
for(i = 0; i < arr.length; arr++) {
sum += arr[i];
}
return sum
}
function whileSum(arr) {
var sum = 0, i = arr.length;
#lang racket
(require xml net/url)
(define (serve port-no)
(define main-cust (make-custodian))
(parameterize ([current-custodian main-cust])
(define listener (tcp-listen port-no 5 #t))
(define (loop)
(accept-and-handle listener)
(loop))
from flask import Flask
from socialext import SocialExtension
app = Flask(__name__)
social = SocialExtension(app)
@app.route('/')
def index():
return render_template_string("""
@kageurufu
kageurufu / lambda.js
Last active November 25, 2021 12:44
AWS Lambda Thumbnailer
var async = require("async");
var AWS = require("aws-sdk");
var gm = require("gm").subClass({imageMagick: true});
var fs = require("fs");
var mktemp = require("mktemp");
var THUMB_KEY_PREFIX = "thumbnails/",
THUMB_WIDTH = 150,
THUMB_HEIGHT = 150,
ALLOWED_FILETYPES = ['png', 'jpg', 'jpeg', 'bmp', 'tiff', 'pdf', 'gif'];
#!/usr/bin/env python2
import boto
from collections import defaultdict
from pprint import pprint
import os, sys
DIVIDER = """
===========================================
======== ec2-instances ========
[02/17/15 23:44:56] [INFO] Reading configuration file /home/frank/.ngrok
[02/17/15 23:44:56] [INFO] [client] Trusting root CAs: [assets/client/tls/ngrokroot.crt]
[02/17/15 23:44:56] [INFO] [view] [web] Serving web interface on 0.0.0.0:8888
[02/17/15 23:44:56] [INFO] Checking for update
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] New connection to: 96.126.125.171:443
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] Writing message: {"Type":"Auth","Payload":{"Version":"2","MmVersion":"1.7","User":"ZnDxl31mzAgxJhgAb7Tc","Password":"","OS":"linux","Arch":"amd64","ClientId":""}}
[02/17/15 23:44:56] [DEBG] [ctl:374737d0] Waiting to read message
[02/17/15 23:44:57] [DEBG] [ctl:374737d0] Reading message with length: 120
[02/17/15 23:44:57] [DEBG] [ctl:374737d0] Read message {"Type":"AuthResp","Payload":{"Version":"2","MmVersion":"1.7","ClientId":"03f700f2df0a3bc9f2bc5e74606ea8b6","Error":""}}
[02/17/15 23:44:57] [INFO] [client] Authenticated with server, client id: 03f700f2df0a3bc9f2bc5e74606ea8b6
echo Setting OSX values for Virtual Box ${1}
VBoxManage modifyvm "${1}" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "${1}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1