Skip to content

Instantly share code, notes, and snippets.

@JohnAlbin
JohnAlbin / _README.md
Last active March 18, 2024 09:25 — forked from clarkdave/createPages.ts
TypeScript + Gatsby config and node API

README

  1. When Gatsby starts up, it will read gatsby-config.js first.
  2. As you can see below, we use that file to require('ts-node').register() which registers a TypeScript evaluator that will be used when Gatsby reads all other API Javascript files. In other words, we only need to do this once in our entire codebase and not in other Gatsby files like gatsby-node.js.
  3. Our gatsby-config.js re-exports all the exported variables available in gatsby-config.ts.
@evgsil
evgsil / react-vis.d.ts
Last active October 23, 2019 08:15
Type Definitions for react-vis
declare module 'react-vis' {
import {
Component,
PureComponent,
ReactChild,
ReactNode,
SFC,
MouseEventHandler,
TouchEventHandler,
@ada-lovecraft
ada-lovecraft / Bird.js
Last active October 23, 2015 13:28
Phaser 2.0 Tutorial: Flappy Bird (Part 2) : Full tutorial: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-2/
/* Full tutorial: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-2/ */
'use strict';
var Bird = function(game, x, y, frame) {
Phaser.Sprite.call(this, game, x, y, 'bird', frame);
this.anchor.setTo(0.5, 0.5);
// add flap animation and begin playing it
this.animations.add('flap');
this.animations.play('flap', 12, true);
var self = window;
(function(self) {
var canvas, context, particles = [], explode = true, FPS = 60;
/*
* Init.
*/
@st3v
st3v / ssh-host-color
Last active January 31, 2023 00:34
Automatically set background color in iTerm depending on ssh host
#!/bin/bash
#
# ssh into a machine and automatically set the background
# color of Mac OS X Terminal depending on the hostname.
#
# Installation:
# 1. Save this script to /usr/local/bin/ssh-host-color
# 2. chmod 755 /usr/local/bin/ssh-host-color
# 3. alias ssh=/usr/local/bin/ssh-host-color
# 4. export PRODUCTION_HOST="<hostname_production_server>"
@mweppler
mweppler / site-manager.rb
Last active December 13, 2015 20:28
THIS IS STILL A WORK IN PROGRESS... If this is the first time running site-manager use the --setup switch I got tired of manually setting up a new site that I have to work on. I use Pow for RoR, rack/sinatra apps, static html sites, and proxy to apache via port 81 for anything else. This script makes a few assumptions about your environment, and…
#!/usr/bin/env ruby
###############################################################################
# Required Application Libraries #
###############################################################################
%w{ rubygems optparse ostruct socket yaml }.each { |lib| require lib }
###############################################################################
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

@mweppler
mweppler / emailer.rb
Created September 14, 2012 07:13
A ruby emailer
# http://ruby-doc.org/stdlib-1.9.3/libdoc/net/smtp/rdoc/Net/SMTP.html
require 'digest/md5'
require 'mime/types'
require 'net/smtp'
require 'optparse'
require 'ostruct'
require 'yaml'
class Emailer
@tomjn
tomjn / typekit.editor.php
Created September 10, 2012 10:22
Typekit fonts for TinyMCE editor plugin
add_filter("mce_external_plugins", "tomjn_mce_external_plugins");
function tomjn_mce_external_plugins($plugin_array){
$plugin_array['typekit'] = get_template_directory_uri().'/typekit.tinymce.js';
return $plugin_array;
}