Skip to content

Instantly share code, notes, and snippets.

@Nilpo
Nilpo / Log-.md
Last active September 4, 2015 01:19 — forked from bgrins/Log-.md
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@Nilpo
Nilpo / call-apply-bind-proxy.js
Last active September 16, 2015 04:00 — forked from branneman/call-apply-bind-proxy.js
JavaScript call() vs apply() vs bind() vs $.proxy()
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
@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>
@Nilpo
Nilpo / colors.xml
Last active September 12, 2022 16:50 — forked from drewis/colors.xml
Material design color palettes for Android
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- app color palette -->
<color name="primary">@color/indigo_500</color>
<color name="primary_light">@color/indigo_100</color>
<color name="primary_dark">@color/indigo_700</color>
<color name="accent">@color/pink_A200</color>
<color name="accent_fallback_light">@color/pink_A100</color>
<color name="accent_fallback_dark">@color/pink_A400</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 / 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
@Nilpo
Nilpo / gist:defc4feacbb71f79cf13
Created January 29, 2016 06:48 — forked from max/gist:5708466
Flat UI Colors as Sass variables
// I needed flatuicolors.com as Sass variables...
// In your console, run:
$('.color').get().map(function(el) { return "$" + el.classList[1] + ": " + el.getAttribute('data-clipboard-text') + ';' }).join('\r\n');
// Output:
// $turquoise: #1abc9c;
// $emerland: #2ecc71;
// $peter-river: #3498db;
// $amethyst: #9b59b6;
// $wet-asphalt: #34495e;
@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();
@Nilpo
Nilpo / MapAdjust.java
Created April 19, 2016 02:54 — forked from codebutler/MapAdjust.java
Code to offset Android Google Map positions in pixels.
// MapAdjust.java
// Based on adjust.py
// Gatubit <gatubit@gmail.com>
// https://gist.github.com/astrocosa/724526
// Based on adjust.js
// Bratliff <bratliff@umich.edu>
// http://www.polyarc.us/adjust.js
@Nilpo
Nilpo / allow
Created September 16, 2016 01:40 — forked from Mteigers/allow
CSF Allow AND Ignore Cloudflare IPv4 IP's.
for i in `curl https://www.cloudflare.com/ips-v4`; do csf -a $i; done