Skip to content

Instantly share code, notes, and snippets.

Avatar

Bradley Farias bmeck

View GitHub Profile
View screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
View screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@bmeck
bmeck / starttls.js
Created Apr 26, 2011 — forked from TooTallNate/starttls.js
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
View starttls.js
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
View async-example.js
var directories = [
'./app',
'./app/controllers',
'./app/helpers',
'./app/repositories',
'./app/validations',
'./app/views',
'./app/views/partials'
]
View gist:8110130
function collectLikes(arr) {
arr = Array.prototype.slice.call(arr);
if (arr.length) {
// our current type
var current_type = typeof arr[0];
// our start of type
var left = 0;
return arr.reduce(function (current, value, index, arr) {
// only need to do work if type is different
if (typeof value !== current_type) {
@bmeck
bmeck / echoHttpRequest.js
Last active Aug 29, 2015 — forked from Marak/echoHttpRequest.js
Transparent log http req
View echoHttpRequest.js
module['exports'] = function echoHttp (hook) {
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
hook.req.pipe(hook.res);
View example.md
`/my-website/` - `package.json`
`/src/`
`/pages/` - `index.html` - `about.html`
`/assets/` - `site.css` - `site.js`
@bmeck
bmeck / hmr.js
Created Mar 20, 2020 — forked from georges-gomes/hmr.js
Hot module reload prototype
View hmr.js
import inspector from "inspector";
const url2scriptid = new Map<string, string>();
const session = new inspector.Session();
session.connect();
setupDebugger();
function setupDebugger() {
You can’t perform that action at this time.