Skip to content

Instantly share code, notes, and snippets.

# You will need to make this file executable (chmod u+x) and run it with sudo
apt-get update
apt-get --fix-missing -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk
mkdir -p /src/erlang
cd /src/erlang
wget http://www.erlang.org/download/otp_src_R16B03-1.tar.gz
tar -xvzf otp_src_R15B01.tar.gz
chmod -R 777 otp_src_R15B01
cd otp_src_R15B01
./configure
@santoshrajan
santoshrajan / JSONStringify.swift
Created October 12, 2014 05:36
JSON Stringify in Swift
// Author - Santosh Rajan
import Foundation
let jsonObject: [AnyObject] = [
["name": "John", "age": 21],
["name": "Bob", "age": 35],
]
func JSONStringify(value: AnyObject, prettyPrinted: Bool = false) -> String {
@benvium
benvium / TopCropImageView.java
Created January 23, 2014 13:18
Android ImageView subclass that (1) fills the image to the width of the image view (2) aligns to the bottom edge (3) crops off the top
/**
* Align image to bottom, fill width. and crop top if needed.
*
* http://stackoverflow.com/questions/6330084/imageview-scaling-top-crop
* https://gist.github.com/arriolac/3843346
*/
import android.content.Context;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.widget.ImageView;
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@cnnrhill
cnnrhill / ListViewScrollTracker.java
Created September 24, 2013 04:24
Helper class for calculating relative scroll offsets in a ListView or GridView by tracking the position of child views.
import android.util.SparseArray;
import android.widget.AbsListView;
/**
* Helper class for calculating relative scroll offsets in a ListView or GridView by tracking the
* position of child views.
*/
public class ListViewScrollTracker {
private AbsListView mListView;
private SparseArray<Integer> mPositions;
@msng
msng / strpos_array.php
Last active June 28, 2022 20:15
PHP: strpos_array is strpos that can take an array as needle
<?php
function strpos_array($haystack, $needles, $offset = 0) {
if (is_array($needles)) {
foreach ($needles as $needle) {
$pos = strpos_array($haystack, $needle);
if ($pos !== false) {
return $pos;
}
}
return false;
@andreiz
andreiz / classifier.php
Last active July 12, 2022 12:50
A simple example of logistic regression via gradient descent in PHP.
<?php
error_reporting(E_ALL);
define('NUM_FEATURES', 3);
// My dataset describes cities around the world where I might consider living.
// Each sample (city) consists of 3 features:
// * Feature 1: average low winter temperature in the city
// * Feature 2: city population, in millions
@dstroot
dstroot / performance.txt
Created May 25, 2012 01:27
Performance Tuning your TCP Stack
#!/bin/bash
echo "*****************************************"
echo " Based on information from Google"
echo " http://dev.chromium.org/spdy/spdy-best-practices"
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Changing initcwnd and initrwnd"
echo " Step 1: check route settings."
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software