Skip to content

Instantly share code, notes, and snippets.

@dannyid
dannyid / HowToOTGFast.md
Created March 27, 2017 03:40 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH is

@dannyid
dannyid / private-fork.md
Created February 10, 2017 07:40 — forked from DavideMontersino/private-fork.md
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new changes (will be called upstream)

How to make a private fork from github to gitlab

@dannyid
dannyid / docker-regenerate-certs.sh
Created November 21, 2016 06:10
Fix Docker reboot IP/cert mismatch problem
docker-machine regenerate-certs
@dannyid
dannyid / disable-notification-center.sh
Created November 21, 2016 05:41
How to disable Notification Center on macOS
# Disabling Notification Center
# “process not found” error shouldn't matter
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
killall NotificationCenter
# Enabling Notification Center
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
@dannyid
dannyid / javascript-puzzle.js
Last active November 28, 2016 04:13
Javascript puzzle.
// Given:
var i = '1';
// 1. What is the value of the below expression?
// 2. What is the value of `i` afterwards?
++i + +i+++i+i +++i+i+i+++i++ +i+++i;
@dannyid
dannyid / team-treehouse-download-video-bookmarklet.md
Last active September 14, 2016 09:19
Download the video you're currently watching on TeamTreehouse.com

###What does it do?

Downloads the HD version of the Team Treehouse video you're currently watching.

###How to use:

  1. Right click on your bookmarks bar and choose Add Page...
  2. Give it a name and paste the below code in the URL section
@dannyid
dannyid / Spread.md
Last active February 10, 2017 07:58
Updating Deep Immutable Object with ES6 Spread. From: https://github.com/sebmarkbage/ecmascript-rest-spread/blob/master/Spread.md

Updating Deep Immutable Object

let newVersion = {
  language: 'Default Language', // Set default for unspecified properties
  ...previousVersion,
  name: 'New Name', // Override the name property
  address: {
    ...previousVersion.address,
    zipCode: '99999' // Update nested zip code
 },
@dannyid
dannyid / calculateColorContrast.js
Last active October 8, 2015 21:18
Find the best contrast color to overlay onto given color.
export function getContrastYIQ(color, colorType){
let r, g, b;
const start = color.indexOf('#') === 0 ? 1 : 0;
if (colorType === 'hex') {
r = parseInt(color.substr(start, 2), 16);
g = parseInt(color.substr(start + 2, 2), 16);
b = parseInt(color.substr(start + 4, 2), 16);
} else if (colorType == 'rgb') {
[r, g, b] = color.slice(4, -1).split(',').map(str => +str);
@dannyid
dannyid / copyToClipboard.js
Created September 25, 2015 06:34
For use in a Chrome extension. Don't forget to enable the "clipboardWrite" permission.
function copyToClipboard(text) {
const input = document.createElement('input');
input.style.position = 'fixed';
input.style.opacity = 0;
input.value = text;
document.body.appendChild(input);
input.select();
document.execCommand('Copy');
document.body.removeChild(input);
};
@dannyid
dannyid / googleSearchUrl.js
Last active May 30, 2017 03:40
What do these parameters even mean?
const language = `en`,
numResults = `100`, // 1 to 100
personalization = `0`, // Non-personalized
encoding = `UTF-8`,
verbatim = `li:1`, // No auto-correct and no location
ssl = `ssl`;
const googleSearchUrl = `https://www.google.com/search` +
`?q=${keyword}` +
`&hl=${language}` +