Skip to content

Instantly share code, notes, and snippets.

View rdmurphy's full-sized avatar
🔴
Red pandas are the best.

Ryan Murphy rdmurphy

🔴
Red pandas are the best.
View GitHub Profile
@brandondurham
brandondurham / styles.less
Last active June 24, 2024 14:48
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@gboone
gboone / midpoint
Created November 28, 2015 23:47
How to find a geographic midpoint in js
function setLatLng(dataset) {
var lat = dataset.lat
var lng = dataset.lng
return new L.LatLng(lat, lng)
}
function latLngRadians(dataset) {
return _.map(dataset, function(item) {
var latRad = item.lat*(Math.PI/180)
var lngRad = item.lng*(Math.PI/180)
@dgowrie
dgowrie / prototype-pattern.js
Created October 4, 2015 06:44
Yet another iteration of (revealing)Prototype Pattern with private/public methods
var myPrototypeModule = (function() {
'use strict';
var privateVar = 'Alex Castrounis',
count = 0;
function PrototypeModule(name) {
this.name = name;
}
function privateFunction() {
@paulirish
paulirish / what-forces-layout.md
Last active May 13, 2025 17:01
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
var parseCSV = require("./parse-csv.js");
// Call the function, pass a callback as the second arg
parseCSV("data.csv",function(err,rows){
// Did something go wrong?
if (err) {
throw new Error(err);
}
@dgowrie
dgowrie / revealing-prototype-pattern.js
Last active December 18, 2015 17:40
Public / private members on a "class" via the Pseudoclassical pattern using Prototypal Inheritance combined with the Revealing Module pattern - AKA a "revealing prototype pattern"
// constructor
function Person(name) {
this.name = name;
// etc... but no methods here
}
// prototype for all methods, using an IIFE with a returned object for 'public' methods
Person.prototype = (function() {
@addyosmani
addyosmani / package.json
Last active December 28, 2024 12:07
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@dbrgn
dbrgn / mixins.py
Last active September 13, 2018 20:44
Moved to https://github.com/dbrgn/drf-dynamic-fields
@donohoe
donohoe / index.html
Created April 15, 2014 22:39
Super simple basic hacky NYTimes API that hooks into their JSONP feeds
<html>
<head>
<title>Super Simple Sandbox</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<script src="nyt.js"></script>
</body>
</html>