Skip to content

Instantly share code, notes, and snippets.

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

###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 Feb 10, 2017 — forked from DavideMontersino/private-fork.md
How to fork to a private gitlab instance
View private-fork.md

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 Nov 21, 2016
Fix Docker reboot IP/cert mismatch problem
View docker-regenerate-certs.sh
docker-machine regenerate-certs
@dannyid
dannyid / disable-notification-center.sh
Created Nov 21, 2016
How to disable Notification Center on macOS
View disable-notification-center.sh
# 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 Nov 28, 2016
Javascript puzzle.
View javascript-puzzle.js
// 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 Sep 14, 2016
Download the video you're currently watching on TeamTreehouse.com
View team-treehouse-download-video-bookmarklet.md

###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
View 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 Oct 8, 2015
Find the best contrast color to overlay onto given color.
View calculateColorContrast.js
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 Sep 25, 2015
For use in a Chrome extension. Don't forget to enable the "clipboardWrite" permission.
View copyToClipboard.js
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
What do these parameters even mean?
View googleSearchUrl.js
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}` +