Skip to content

Instantly share code, notes, and snippets.

⚡️
bam

Jo Colina jsmrcaga

⚡️
bam
Block or report user

Report or block jsmrcaga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:bb0defcdcd1bdcc21a3e961482c490ef
Verifying my Blockstack ID is secured with the address 12ZijDjYwb1us93s3JT8JMXKs2f8FBE1aa https://explorer.blockstack.org/address/12ZijDjYwb1us93s3JT8JMXKs2f8FBE1aa
@jsmrcaga
jsmrcaga / version-args.js
Created May 1, 2019
A simple version reporter
View version-args.js
if (process.argv && process.argv.indexOf('-v') > -1) {
const { name, version } = require('./package.json');
return console.log(`${name} version ${version}`);
}
/*
Example:
node mystuff.js -v
> mystuff version 3.0.4
@jsmrcaga
jsmrcaga / webauthn.md
Last active Mar 7, 2019
WebAuthn API compilation
View webauthn.md

WebAuthn Protocol

Utility

ArrayBuffer.from = (string) => Uint8Array.from(string.split('').map(e => e.charCodeAt(0))).buffer;

let challenge = ArrayBuffer.from('super hard challenge created in server');
let id = ArrayBuffer.from('id created in server')

@jsmrcaga
jsmrcaga / webauthn.md
Created Mar 7, 2019
WebAuthn API compilation
View webauthn.md

WebAuthn Protocol

Utility

ArrayBuffer.from = (string) => Uint8Array.from(string.split('').map(e => e.charCodeAt(0))).buffer;

let challenge = ArrayBuffer.from('super hard challenge created in server');
let id = ArrayBuffer.from('id created in server')

View sigint.js
// INSTRUCTIONS
/*
* 1) Run node sigint.js and call ctrl-c, then wait 1 second (for process to exit)
* Expected output: SIGINT 1
*
* 2) Run npm start (see end of file for example, which runs node sigint.js) and call ctrl-c, then wait 1 second (for process to exit)
* Expected output SIGINT 1
* Unexpected output SIGINT 2
*/
View csv-to-json.js
const fs = require('fs');
console.time('Reading CSV...');
let csv = fs.readFileSync('./rocket.csv', {encoding: 'utf8'});
console.timeEnd('Reading CSV...');
let lines = csv.split('\n');
let names = lines.splice(0,1)[0].split(';');
console.log('Got names', names.join(', '));
console.log('And', lines.length, 'lines');
@jsmrcaga
jsmrcaga / Git Magic
Created Dec 13, 2016
Command to auto rebase a branch from another.
View Git Magic
[alias]
magic = "!sh -c 'git checkout \"$1\" && git pull && git checkout \"$0\" && git rebase \"$1\"'"
@jsmrcaga
jsmrcaga / ClosingTabsTimes.js
Created Aug 18, 2016
a small script to get the time needed to close a tab
View ClosingTabsTimes.js
// Closing time with mouse, trackpad and keyboard
;(function(){
var begin = null;
var mouseMoved = false;
window.times = {
mouse: [],
keyboard: [],
trackpad: [],
};
@jsmrcaga
jsmrcaga / getElementsByAttributeName.js
Created Jul 30, 2016
Function to get all elements that have an attribute that starts with a given string
View getElementsByAttributeName.js
function getElementsByAttributeName(startsWith, type){
return Array.from(document.querySelectorAll(type || '*')).filter(function(el){
var ok = false;
Array.from(el.attributes).forEach( function(attr){
if(startsWith instanceof RegExp){
ok = attr.name.match(startsWith);
} else {
ok = attr.name.startsWith(startsWith);
}
});
@jsmrcaga
jsmrcaga / workshop-add.js
Created Jul 24, 2016
Add Workshop from console
View workshop-add.js
var s = document.createElement('script');
s.src = 'https://jocolina.tk/workshop/workshop.min.js';
document.body.appendChild(s);
You can’t perform that action at this time.