Skip to content

Instantly share code, notes, and snippets.

View sterlingwes's full-sized avatar
🍉

Wes Johnson sterlingwes

🍉
View GitHub Profile
@dlukez
dlukez / ngTagsInput-restrictToMaxTags.js
Last active November 7, 2019 16:53
A directive that extends mbenford/ngTagsInput to hide the tags input when the max tags limit is been reached.
/**
* A directive to hide the tags input when the max tags limit is reached.
* Works with github.com/mbenford/ngTagsInput
*/
angular.module('dz.restrictToMaxTags', ['ngTagsInput']).directive( 'restrictToMaxTags', function () {
var KEY_BACKSPACE = 8
KEY_TAB = 9;
return {
require: 'ngModel',
@phette23
phette23 / clip.js
Created June 18, 2014 23:55
Pipe to Clipboard in Node.js (Mac OS X only)
var clipboard = require('child_process').spawn('pbcopy')
, data = 'put whatever data here';
clipboard.stdin.write(data);
clipboard.stdin.end();
@maxim
maxim / task.yml
Created June 12, 2014 11:09
Adding github to known_hosts with ansible
- name: ensure github.com is a known host
lineinfile:
dest: /root/.ssh/known_hosts
create: yes
state: present
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"
regexp: "^github\\.com"
@asmallteapot
asmallteapot / .gitattributes
Last active March 31, 2022 11:43
Diff Xcode localizable strings files in Git.
*.strings utf16 diff=localizablestrings
@branneman
branneman / better-nodejs-require-paths.md
Last active April 27, 2024 04:16
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@dylants
dylants / myapp.conf
Last active October 8, 2018 16:29
upstart config file for running node.js on a linux machine. This uses nodemon to allow file changes when pulled from git. This also specifies the NODE_ENV environment variable as "production" which would trigger the app to production mode (as opposed to development). Remove the environment variable if development environment is desired.
#!upstart
description "nodemon server for myapp"
author "ubuntu"
start on startup
stop on shutdown
script
export HOME="/home/ubuntu/git/myapp"
@gabrielhpugliese
gabrielhpugliese / meteor-windows-vagrant-tutorial.md
Last active April 19, 2022 14:37
Tutorial for running Meteor in Windows using Vagrant

Tutorial: Meteor in Windows using Vagrant

BEFORE YOU CONTINUE:

  • Now, Meteor runs in any Windows without any line of this tutorial. Just download the Meteor binary! Yay!!
  • mrt is no longer used with Meteor 1.0

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on

@bgrins
bgrins / Log-.md
Last active August 1, 2023 16:32
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,
# Support running Whenever cron jobs with Lockrun
# Lockrun: http://www.unixwiz.net/tools/lockrun.html
# lockrun typically installed at /usr/bin/lockrun
# On Mac, install with: brew install lockrun
# Lockrun prefix for cronjobs: /usr/bin/lockrun --lockfile=/path/to/tmp/JOBNAME.lockrun -- sh -c "COMMAND"
def wrap_with_lockrun command
"/usr/bin/env lockrun --lockfile=:path/tmp/:lockfile.lockrun -- sh -c \"#{ command }\""
end
#redefine the three default job types to use Lockrun (i.e. just add 'lockrun_' in front of the existing job names)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: