Skip to content

Instantly share code, notes, and snippets.

Avatar

Luke lukem512

View GitHub Profile
@lukem512
lukem512 / atof.c
Last active Jan 16, 2022
ASCII to Float in C
View atof.c
/* Onlu needed for printf() */
#include <stdio.h>
/* Boolean types - comment if not needed */
typedef int bool;
#define true 1
#define false 0
/* !Boolean types */
/* There are also built-in functions for these */
@lukem512
lukem512 / babel.md
Created May 15, 2017
Setting up babel, a beginners guide
View babel.md

Setting up Babel

  1. Install babel-cli and save it to your developer dependencies
npm i --save-dev babel-cli
  1. Install a preset of your choice. Presets indicate which version of EcmaScript to use. The env preset is the most recent version.
@lukem512
lukem512 / maxcoin-validator.js
Created May 12, 2017
Validate a MaxCoin address
View maxcoin-validator.js
// node imports
var sys = require('sys');
var base58 = require('bs58');
var SHA3 = require('sha3');
// validation function
function validateAddress(address) {
// network/version byte
var version = address.substring(0, 1);
if (version != 'm') return false;
@lukem512
lukem512 / btcbal.py
Created May 12, 2017
Retrieve Bitcoin address balance from Blockchain API
View btcbal.py
#!/usr/bin/python
import sys
import getopt
import urllib2
from optparse import OptionParser
def main():
# variables
btcaddr = ""
@lukem512
lukem512 / cryptodistribution.c
Created May 12, 2017
Computes cryptocurrency distribution
View cryptodistribution.c
// Tool for working out cryptocurrency distribution rates
// Luke Mitchell, 2014
#include "stdlib.h"
#include "stdio.h"
int main (int argc, char** argv) {
printf ("Cryptodistribution tool\n");
printf ("=======================\n\n");
@lukem512
lukem512 / SvgHOC.js
Created May 12, 2017
Convert an SVG React component to React Native
View SvgHOC.js
/* @flow */
import React from 'react';
import Svg, {
Circle,
Ellipse,
G,
LinearGradient,
RadialGradient,
@lukem512
lukem512 / Emoji Consensus.md
Created May 11, 2017
Democratic consensus using Emoji
View Emoji Consensus.md

Emoji Consensus

👍 I concur! I agree with the proposal.

👎 Veto! I disagree with the proposal.

👉 I feel this needs more discussion.

👊 I have no opinion or don't wish to participate in this decision.

@lukem512
lukem512 / dbte.js
Created Mar 21, 2017
Dense Binary Text Encoding
View dbte.js
// Dense Binary Text Encoding
// Encode each of the 26 letter as 1 to 26, in binary.
// Encode spaces as 0.
const ASCII_A = 65;
const ENCODED_SPACE = 0;
function dbte(str) {
const digits = str.toUpperCase().split('');
const encoding = digits.reduce((obj, d, i) => {
@lukem512
lukem512 / toggle_wifi.sh
Created Mar 19, 2017
Toggle WiFi networks (OSX)
View toggle_wifi.sh
#! /bin/sh
ssid1="THEUNIVERSE"
pass1="yourpass"
ssid2="SPACE"
pass2="yourotherpass"
curr=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'`
echo Currently connected to $curr
echo Power cycling...
View marnagas.js
// Sort the strings alphabetically, then sort the strings by length
// Naively compare each string to the others and try to find anagrams.
function hasAnagram(strings) {
const sorted = strings.map(s => s.split("").sort().join("")).sort();
return sorted.some((s, i) => {
const sliced = sorted.slice(0, i).concat(sorted.slice(i+1));
return sliced.find(s2 => s == s2);
});
}