Skip to content

Instantly share code, notes, and snippets.

View basecss's full-sized avatar
🎯
Focusing

basecss basecss

🎯
Focusing
  • China
  • 15:19 (UTC +08:00)
View GitHub Profile
@mathisonian
mathisonian / index.md
Last active August 10, 2024 20:59
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

# SYNTAX:
var pattern = new RegExp(pattern, attributes); # attributes: g (global); i (case-sensitive); m (multiline matches)
var pattern = /pattern/attributes; # same as above
# BRACKETS:
[...]: Any one character between the brackets.
[^...]: Any one character not between the brackets.
@Rich-Harris
Rich-Harris / promise.js
Last active August 27, 2022 14:59
ES6 Promise polyfill
( function ( global ) {
'use strict';
var Promise, PENDING = {}, FULFILLED = {}, REJECTED = {};
if ( typeof global.Promise === 'function' ) {
Promise = global.Promise;
} else {
Promise = function ( callback ) {
@getify
getify / gist:9403543
Created March 7, 2014 01:51
JSON.pretty
if (!JSON.pretty) {
JSON.pretty = function jsonpretty(o,f,indent) {
f = (f !== undefined) ? f : null;
indent = (indent !== undefined) ? indent : "\t";
return JSON.stringify(o,f,indent);
};
}
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 20, 2025 13:11
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@mollerse
mollerse / gulpfile-express.js
Last active March 28, 2021 20:07
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@es
es / functional.js
Created December 8, 2013 20:55
Implementation of Curry, Uncurry, & Compose functions (with accompanying tests).
/*
* Curry takes a two argumented function and returns one func that returns a second func that each take one argument.
*/
function curry (func) {
return function (x) {
return function (y) {
return func (x, y);
};
};
@yorkxin
yorkxin / README.md
Created September 16, 2013 06:43
HTML / Markdown filters by GitHub

html-pipeline: 把 text formatting 做成一層一層的 filter 接成 pipeline

linguist: 自動偵測一段文本或檔案的程式語言, GitHub 本身用它來偵測你專案使用的程式語言

charlock_holmes: 自動偵測文本的文字編碼,來自一個叫做 ICU 的資料庫,不知道是什麼,搜集了一堆文字編碼資訊和地區格式。

github-markdown: 實際在 GitHub 使用的 markdown compiler ,我找不到公開的 repo ,但程式碼是 MIT license ,很神秘…

github-markup: 用來把 README.md 這種檔案給 render 成 HTML

@ichiriac
ichiriac / jPrototype.php
Last active December 21, 2015 20:49
An experiment to implement the Javascript Prototype principle in PHP 5.3
<?php
class jPrototype {
protected static $prototype = array();
public static function prototype() {
if ( !self::$prototype ) {
self::$prototype = new self();
}
return self::$prototype;
}
public function __set($property, $value) {
@ebidel
ebidel / Web Components Resources.md
Last active October 12, 2024 17:10
List of resources related to Web Components