Skip to content

Instantly share code, notes, and snippets.

@Nilpo
Nilpo / playingcards.js
Created September 22, 2015 23:24
Playing Cards in JavaScript
// Create a function for shuffling the elements in an array
Array.prototype.shuffle = function(repeat) {
repeat = (repeat === undefined) ? 1 : repeat;
for (var i = 0; i < repeat; i++) {
// Implement the Fisher-Yates Shuffle
var currentIndex = this.length, temporaryValue, randomIndex;
@Nilpo
Nilpo / android_material_design_colours.xml
Last active October 26, 2015 00:40 — forked from daniellevass/android_material_design_colours.xml
Android Material Design Colours
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
// --------------------------------------------------------------------------------------
// A More Modern Scale for Web Typography
// Based on this article: http://typecast.com/blog/a-more-modern-scale-for-web-typography
// --------------------------------------------------------------------------------------
$body-font-size: 1em !default;
// Adjusts body typography to be default
// for each browser.
@mixin reset-body-font-size($font-size: 100%, $size-adjustment: 0.5) {
@Nilpo
Nilpo / pdf.php
Created November 21, 2015 04:39
Serving PDF Files While Retaining Canonicalization
<?php
/**
* A sample file used for serving PDF files while retaining canonicalization.
*
* You will need something like the following in .htaccess:
*
* RewriteRule ^(.+)\.pdf /pdf.php?file=$1 [L]
*/
@Nilpo
Nilpo / ttf2woff2.md
Created December 22, 2015 23:35 — forked from sergejmueller/ttf2woff2.md
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
// github gist Shortcode Usage: [gist id="" file=""]
function gist_shortcode( $atts ) {
extract(shortcode_atts(array(
'id' => '',
'file' => ''
), $atts));
return '<script src="https://gist.github.com/'.$id.'.js?file='.$file.'"></script>';
}
add_shortcode('gist', 'gist_shortcode');
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="An example of simple JavaScript animation for HTML5 meters and progress bars." />
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<p><meter id="meter" value="300" min="0" max="500">300Gb of 500Gb</meter></p>
@Nilpo
Nilpo / Sublime Text 2 HTML5 Boilerplate Snippet
Last active January 4, 2016 23:16 — forked from keithforsythe/Sublime Text 2 HTML5 Boilerplate Snippet
Sublime Text 2 HTML5 Boilerplate snippet. Creates an HTML5 page structure based on the HTML5 Boilerplate project - with all the components included - when you type ht5, tab. To use: 1. Copy this text into a new doc with the syntax mode set to xml. 2. Then save it to "/Packages/User/html5-boilerplate.sublime-snippet". Document must be in HTML syn…
<snippet>
<content><![CDATA[<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>${1:Project Name}</title>
@Nilpo
Nilpo / backup.sh
Created December 15, 2015 01:10
Website backup script
#!/bin/bash -x
NOW=$(date +"%Y-%m-%d-%H%M)
FILE="domain.com.$NOW.tar"
BACKUP_DIR="/home/user/backups"
WWW_DIR="/home/user/domain.com/"
DB_HOST="mysql.domain.com"
DB_USER="dbuser"
DB_PASS="dbpass"
DB_NAME="dbname"
@Nilpo
Nilpo / JsonHelper.java
Created April 19, 2016 02:46 — forked from codebutler/JsonHelper.java
Convert Android JSONObject/JSONArray to a standard Map/List.
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
public class JsonHelper {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof Map) {
JSONObject json = new JSONObject();