Skip to content

Instantly share code, notes, and snippets.

View DarrylD's full-sized avatar
💭
daydreaming

Darryl D. DarrylD

💭
daydreaming
View GitHub Profile
@royto
royto / ES6 Angular Directive with injection
Last active October 25, 2017 18:01
Example of Angular Directive as ES6 class with injection
class myDirective {
constructor(userService) {
this.template = `<div>{{fullName}}</div>`;
this.restrict = 'E';
this.scope = {
user: '='
};
this.link = function(scope, element) {
scope.fullName = userService.getFullName(scope.user);
};

Usage

  1. npm install babel-loader imports-loader webpack --save
  2. Create webpack.config.js
  3. Move index.ios.js to src/index.ios.jsx
  4. webpack --watch

Example

src/index.ios.jsx

@danharper
danharper / circle.yml
Created February 11, 2015 12:46
How we deploy InventoryBase from CircleCI
machine:
php:
version: 5.6.5
dependencies:
cache_directories:
- vendor
- node_modules
pre:
- sudo pip install awscli
@jiaaro
jiaaro / hotkey_helpers.js
Last active February 27, 2023 22:01
Mac Automation – Javascript (JSX) Hotkey helpers
// How to use:
// 1. Open "Script Editor" (requires OS X 10.10 Yosemite)
// 2. Change the language from "AppleScript" to "JavaScript"
// 3. Paste the code below and replace the safari example.
//
// More info:
// https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html
var sys_events = Application("System Events");
@wh1tney
wh1tney / deploy-static-site-heroku.md
Last active May 25, 2024 22:28
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@staltz
staltz / introrx.md
Last active May 27, 2024 03:11
The introduction to Reactive Programming you've been missing
##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@rjeczalik
rjeczalik / toggle-camera.bash
Created January 5, 2014 12:32
load/unload AppleCameraInterface
#!/usr/bin/env bash
toggle-camera() {
if kextstat | grep AppleCameraInterface &>/dev/null; then
for ((i=0; i<3; i++)); do
if sudo kextunload /System/Library/Extensions/AppleCameraInterface.kext &>/dev/null; then
echo "toggle-camera: AppleCameraInterface unloaded"
return 0
fi
done
@Bunkerbewohner
Bunkerbewohner / guid.js
Created June 27, 2013 12:19
Generating a GUID for javascript applications and storing it in HTML5 local strorage.
function generate_guid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
function get_guid() {
if (window.localStorage.guid != null) {
@mharsch
mharsch / gist:5188206
Last active February 8, 2024 02:43
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory