Skip to content

Instantly share code, notes, and snippets.

View futurist's full-sized avatar

James Yang futurist

  • China
View GitHub Profile
@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active September 8, 2024 21:36
SVG Icons with mithril.js

Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.

They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.

A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  
  <symbol id="beaker" viewBox="214.7 0 182.6 792">
@joyrexus
joyrexus / README.md
Last active September 7, 2024 14:28
Form/file uploads with hapi.js

Demo of multipart form/file uploading with hapi.js.

Usage

npm install
npm run setup
npm run server

Then ...

@kevincennis
kevincennis / v8.md
Last active May 18, 2025 14:37
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)
@kishmiryan-karlen
kishmiryan-karlen / Apply LUT (LookUpTable).js
Created August 13, 2014 12:59
A function that helps to apply LUT to image. Make sure to change the canvas IDs or to create temporary canvases.
/**
* Created by Karlen on 13-Aug-14.
*/
var imageContext = document.getElementById('imageCanvas').getContext('2d'),
lutContext = document.getElementById('lutCanvas').getContext('2d');
function applyLUT(image, lut) {
var imageData, lutData, iData, lData;
@juanbrujo
juanbrujo / randomColor.less
Created July 9, 2014 02:46
Mixin to generate random color in LESS
.randomColor(){
@randomColor: `Math.floor(Math.random()*16777215).toString(16)`;
@colorHex: e(@randomColor);
@color: ~"#@{colorHex}";
}
// USE
body {
.randomColor();
@sheharyarn
sheharyarn / mongo_backup.sh
Last active December 12, 2024 15:16
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing
@cjihrig
cjihrig / Proxying Server Sent Events Using Hapi.md
Last active June 24, 2017 03:56
Proxying Server Sent Events Using Hapi
  1. Place server.js and sse.html in the same directory
  2. npm install hapi nipple
  3. node server.js
  4. In browser that supports Server Sent Events, navigate to http://localhost:3000/sse.html
  • Navigating to this page triggers a connection to /stream.
  • /stream connects to /events and proxies the data back to the client.
  • /events provides the actual Server Sent Events stream.
@totherik
totherik / gist:3a4432f26eea1224ceeb
Last active March 15, 2025 06:06
v8 --allow-natives-syntax RuntimeFunctions
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc
%CreateSymbol
%CreatePrivateSymbol
%CreateGlobalPrivateSymbol
%NewSymbolWrapper
%SymbolDescription
%SymbolRegistry
%SymbolIsPrivate
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote