Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Carlos killerbytes

  • SMILEUPPS-EEAA4883DF
  • SMILEUPPS-EEAA4883DF
View GitHub Profile
@killerbytes
killerbytes / downloadFile.js
Created Dec 26, 2020 — forked from davalapar/downloadFile.js
Download response.data as a file, through Blob()
View downloadFile.js
// 'downloadFile.js', written by blending two solutions:
// 'js-download' https://github.com/kennethjiang/js-file-download
// 'Anders Paulsen' https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/
export function downloadFile(data, filename, mime) {
// It is necessary to create a new blob object with mime-type explicitly set
// otherwise only Chrome works like it should
const blob = new Blob([data], {type: mime || 'application/octet-stream'});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE doesn't allow using a blob object directly as link href.
@killerbytes
killerbytes / github_multiple-accounts.md
Created Aug 1, 2019 — forked from JoaquimLey/github_multiple-accounts.md
How to Work with GitHub and Multiple Accounts
View github_multiple-accounts.md

Step 1 - Create a New SSH Key

We need to generate a unique SSH key for our second GitHub account.

ssh-keygen -t rsa -C "your-email-address"

Be careful that you don't over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY. In my case, I've saved the file to ~/.ssh/id_rsa_work.

Step 2 - Attach the New Key

View amazon-converter.js
// ==UserScript==
// @name AMAZON currency converter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.amazon.com/*
// @match https://www.amazon.co.uk/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
View controllers.application.js
import Ember from 'ember';
import DS from 'ember-data';
/**
* Returns true iff the number passed in is even
* @param {Number} x
* @return {Boolean}
*/
function isEven(x) {
return x % 2 == 0;
View url regex
http://rubular.com/r/oFpzy43wUg
((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s]))
View delay
var delay = (function() {
var timer = 0;
return function(callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();
$(window).resize(delay(function() {
someFunction()....
@killerbytes
killerbytes / gist:3485284
Created Aug 27, 2012 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:3485284

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@killerbytes
killerbytes / gist:3280922
Created Aug 7, 2012
CSS: Image Replacement
View gist:3280922
//image replacement
.ir {
font: 0/0 "image replace";
position: relative;
display: inline-block;
background-repeat: none;
}
View gist:3050623
var delay = (function() {
var timer = 0;
return function(callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();
@killerbytes
killerbytes / reset.css
Created Jun 15, 2012 — forked from terkel/reset.css
CSS: Reset
View reset.css
/*!
* CSS Reset 2011-12-25
* https://gist.github.com/gists/1360380
*
* Author: Takeru Suzuki, http://terkel.jp/
* License: Public domain
*
* Inspired by Normalize.css: http://necolas.github.com/normalize.css/
*/