Skip to content

Instantly share code, notes, and snippets.

View bkawk's full-sized avatar

Will Hill bkawk

  • Digital Dreams
  • Earth
View GitHub Profile
@bkawk
bkawk / spp.txt
Created July 15, 2017 00:18
South Park Production
Morning ideas and jokes, in writers meeting
boil down ideas
Not afraid of throwing ideas around
Progression of ideas that ends up being somthing
When ofence is caused they know they have somthing good
Sketches
Inking
Animation
Everybody does everything
fast turn around
@bkawk
bkawk / base64-s3.js
Last active July 14, 2017 17:00
Base64 Image upload to Amazon S3
'use strict';
const aws = require('aws-sdk');
exports.s3PutBase64 = (image, folder, imageName) => {
return new Promise(function(resolve, reject) {
const buf = new Buffer(image.replace(/^data:image\/\w+;base64,/, ""), 'base64');
const s3 = new aws.S3();
aws.config = {
@bkawk
bkawk / assert.js
Created June 12, 2017 12:44
Web component testing cheat sheet
<script>
suite('caja-sanitizer', function() {
test('testdiv is equal to one', function() {
// Setup
var element = fixture('BasicTestFixture');
var elementShadowRoot = element.shadowRoot;
// Select Stuff
var div1 = elementShadowRoot.querySelector('#div1');
var div2 = elementShadowRoot.querySelector('.div2');
@bkawk
bkawk / sql-query.js
Last active May 24, 2017 02:51
Send SQL statement to MySQL
// This file does only one thing it can not call on other functions
const mysql = require('mysql');
const connection = mysql.createConnection({
host : process.env.MYSQL_HOST,
user : process.env.MYSQL_USER,
password : process.env.MYSQL_PASSWORD,
database : process.env.MYSQL_DATABASE
});
@bkawk
bkawk / learn.js
Last active May 29, 2017 22:41
Programming Fundamentals
/**
* START
* --------------------
* Go to http://jsbin.com,
* Hit the X in the top left corner
* Ensure only JavaScript and Console are selected in the midlle
* Enter code in the JavaScript window and see the results in the console
* Copy in each of the blocks below into the jacascript window
* Then in the top right hand cornr of the console press clear and then run
* The coding style and patterns here is the accepted modern norm, you will see older styles in the wild
@bkawk
bkawk / latlng_promise.js
Created April 22, 2017 03:10
Get users Latitude and Longitude
_getPreciseLocation() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
if(position){
resolve([position.coords.latitude, position.coords.longitude]);
} else {
reject(Error("We didnt get a location"))
}
});
@bkawk
bkawk / confg
Last active April 18, 2017 03:21
Nginx with https and SSL
## Make sure we are up to date and install nginx 
sudo apt-get update
sudo apt-get install nginx
## Once completed lets check the version
sudo nginx -v
## OK let’s configure nginx 
sudo nano /etc/nginx/sites-available/default
@bkawk
bkawk / default
Created April 2, 2017 14:36
nginx reverse proxy with caching and SSL for IPFS
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
server {
listen 443 ssl http2 default_server;
@bkawk
bkawk / check-address.js
Created September 19, 2016 12:28
Check BTC Address
$.getScript("../scripts/Sha256.js");
$.getScript("../scripts/BigInt.js");
// ----------------- FUNCTIONS------------------//
function check(address) {
var decoded = base58_decode(address);
if (decoded.length != 25) return false;
var cksum = decoded.substr(decoded.length - 4);
var rest = decoded.substr(0, decoded.length - 4);
function getImage(url){
return new Promise(function(resolve, reject){
var img = new Image()
img.onload = function(){
resolve(url)
}
img.onerror = function(){
reject(url)
}
img.src = url