Skip to content

Instantly share code, notes, and snippets.

View lon-io's full-sized avatar

Excellence Ilesanmi lon-io

View GitHub Profile
@lon-io
lon-io / GZipRequest.java
Created October 31, 2015 18:56 — forked from premnirmal/GZipRequest.java
Parse GZip responses using volley
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.StringRequest;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@lon-io
lon-io / anagram.py
Created May 5, 2017 06:17
Python function to determine if two words are Anagrams of each other
# Determine if an index has been checked
def index_not_in(list_of_indices, index):
res = True
for i in list_of_indices:
if index == i:
res = False
return res
# Determine if 2 strings are anagrams
def anagram(str1, str2):
@lon-io
lon-io / Unique.java
Created May 5, 2017 06:20
Java class with a fucntion to determine the number of unique strings in an array of strings
public class Unique{
public static void main(String [] args){
Unique unique = new Unique();
String[] _args = {"as", "as", "se", "so","so","an","no"};
System.out.println(unique.det(_args));
}
public int det(String [] args_){
@lon-io
lon-io / reverse.py
Created May 5, 2017 06:21
Python script to reverse a given string
# Reverse a given string
def reverse(str):
l = []
for index, i in enumerate(str):
j = len(str)-1 - index
l.append(str[j])
return ''.join(l)
print reverse("asdaad")
@lon-io
lon-io / jsonkeystrip.js
Created June 18, 2017 18:55
Strip the quotes("") off the keys in a JSON Object
let jsonObj = {
"name": "Lon",
"email": "lon@lon.com"
};
console.log(JSON.stringify(jsonObj).replace(/(")(\w*)(")(:)/g, '$2$4'))
@lon-io
lon-io / destructuring.js
Created August 6, 2017 19:54 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@lon-io
lon-io / 1_kubernetes_on_macOS.md
Created March 6, 2018 08:34 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@lon-io
lon-io / gist:36d814a95e2d5c42716298a365249af8
Created July 1, 2018 01:19 — forked from doginthehat/gist:1890659
compare block helper for handlebars
// {{compare unicorns ponies operator="<"}}
// I knew it, unicorns are just low-quality ponies!
// {{/compare}}
//
// (defaults to == if operator omitted)
//
// {{equal unicorns ponies }}
// That's amazing, unicorns are actually undercover ponies
// {{/equal}}
// (from http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/)
@lon-io
lon-io / debounce.js
Created July 3, 2018 17:41
A Javascript function to Debounce other functions
// Debounce function
let debounce = (func, delay) => {
let timeout;
return (...args) => {
// If this function is called again, and there's a timeout defined, clear it;
if (timeout) clearTimeout(timeout);
// Set a timeout to call the original function, after the `delay`
timeout = setTimeout(() => {