This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Spaghett" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message": "Hello, world!" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let asyncawait = true; | |
try { | |
new Function('async function test(){await 1}'); | |
} catch (error) { | |
asyncawait = false; | |
} | |
if (asyncawait) | |
module.exports = require('./lib/Puppeteer'); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Meteor-style client-side database + Redux | |
// kind of a hack. not idiomatic Redux | |
// might become an npm module at some point idk | |
import PouchDB from 'pouchdb' | |
export function databaseReducer(state = {}, action) { | |
if (action.type === 'DATABASE_UPDATE') { | |
return Object.assign({}, state, { [action.db]: action.docs }) | |
} | |
return state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://slides.com/sdrasner/svg-can-do-that#/38 | |
var shape = document.getElementById("shape"); | |
// media query event handler | |
if (matchMedia) { | |
var mq = window.matchMedia("(min-width: 500px)"); | |
mq.addListener(WidthChange); | |
WidthChange(mq); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accept deep-links to Mail.app messages through macOS drag and drop | |
class MailURLDropView: NSView { | |
var filePath: String? | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
self.wantsLayer = true | |
self.layer?.backgroundColor = NSColor.gray.cgColor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sqlite3 chat.db '.schema message' | tr ',' '\n' | |
CREATE TABLE message (ROWID INTEGER PRIMARY KEY AUTOINCREMENT | |
guid TEXT UNIQUE NOT NULL | |
text TEXT | |
replace INTEGER DEFAULT 0 | |
service_center TEXT | |
handle_id INTEGER DEFAULT 0 | |
subject TEXT | |
country TEXT | |
attributedBody BLOB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CMD=$(jq -r .scripts.$1 < package.json) | |
echo -e '\033[37m$ '$CMD'\033[39m' | |
PATH=$PATH:./node_modules/.bin eval "$CMD" | |
echo -e '\xe2\x9c\xa8 Done.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! enum_with_str_representation { | |
(enum $enum_name:ident { | |
$($variant:ident => $nice_name:expr,)+ | |
}) => { | |
#[derive(Debug, PartialEq, Eq, Clone, Hash)] | |
enum $enum_name { | |
$($variant),+ | |
} | |
impl ::std::fmt::Display for $enum_name { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
fn counter() -> Box<FnMut() -> i32 + 'static> { | |
let mut b = 0; | |
let ret = move || { b += 1; b }; | |
Box::new(ret) | |
} | |
#[test] |