Skip to content

Instantly share code, notes, and snippets.

View jzntam's full-sized avatar

Jason Tam jzntam

View GitHub Profile
@jzntam
jzntam / docker-cleanup-resources.md
Created September 3, 2018 20:51 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found

Add Sublime Text to OS X Context Menu

  • Open Automator
  • Create a new Service
  • Add a Run Shell Script action
  • Set input to Service receives selected files or folders in any application
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
  • Set Pass input to as arguments
  • Save as Open in Sublime Text
@jzntam
jzntam / GIF-Screencast-OSX.md
Created November 15, 2017 19:53 — forked from dergachev/GIF-Screencast-OSX.md
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:

@jzntam
jzntam / USER-bh_core.sublime-settings
Created December 20, 2016 16:23 — forked from notbrain/USER-bh_core.sublime-settings
change brackethighlighter colors
{
"bracket_styles": {
"default": {
"icon": "dot",
// BH1's original default color for reference
// "color": "entity.name.class",
"color": "brackethighlighter.default",
"style": "highlight"
@jzntam
jzntam / routes.md
Created December 3, 2016 11:33 — forked from dideler/routes.md
Rails Routes

A summary of the Rails Guides on Routes, plus other tips.

The Rails router recognizes URLs and dispatches them to a controller's action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views.

Examples

# Redirects /orders/report to orders#report.
get 'orders/report', to: 'orders#report'
@jzntam
jzntam / rails-apis.md
Created December 3, 2016 11:33 — forked from dideler/rails-apis.md
From Code School's Zombies series

API Best Practices

Routes

Restricting routes

resources :zombies, only: [:index, :show]
resources :humans, except: [:destroy, :edit, :update] 
apm install linter
gem install rubocop
apm install linter-rubocop

Fisher-Yates Knuth Method

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex ;

  // While elements are avaiable to shuffle
  while (0 !== currentIndex) {

 // Pick an element
@jzntam
jzntam / 0_reuse_code.js
Created December 28, 2015 23:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console