Skip to content

Instantly share code, notes, and snippets.

View futurist's full-sized avatar

James Yang futurist

  • China
View GitHub Profile
@mizchi
mizchi / webpack.config.js
Last active December 6, 2019 21:20
minimum webpack with babel
/*
yarn init -y
yarn add webpack webpack-cli webpack-serve html-webpack-plugin -D
yarn add babel-loader@^8.0.0-beta @babel/core @babel/preset-env -D
echo '{ "presets": ["@babel/preset-env"] }' > .babelrc
*/
const HtmlPlugin = require("html-webpack-plugin");
module.exports = {
mode: process.env.NODE_ENV || "development",
@nick3499
nick3499 / filter_map_collect.rs
Last active May 26, 2020 13:10
Rust: Filter Range, Map, Collect
fn main() {
let rng = 0..30;
let rng_even_cubed = rng.filter(|n| is_even(*n))
.map(|n| n * n * n)
.collect::<Vec<i32>>();
println!("{:?}", rng_even_cubed);
}
fn is_even(n: i32) -> bool {
n % 2 == 0
@JamieMason
JamieMason / es6-compose.md
Last active May 17, 2022 17:38
ES6 JavaScript compose function

ES6 JavaScript Compose Function

Definition

const compose = (...fns) =>
  fns.reduceRight((prevFn, nextFn) =>
    (...args) => nextFn(prevFn(...args)),
    value => value
 );
@jgsqware
jgsqware / kubeadm-install-offline.md
Last active January 22, 2025 09:34
Offline Kubeadm install

On master and nodes

Pull images form internet access laptop

docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-proxy-amd64:v1.5.0
docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.5.0
docker pull weaveworks/weave-npc:1.8.2
docker pull weaveworks/weave-kube:1.8.2
@nchevobbe
nchevobbe / create-dom-element.js
Last active August 22, 2021 12:03
Utility function to create DOM element
/**
* Utility function to create DOM element with populated attributes and content
*
* Usage :
*
* // simple element
* let input = createDomElement("input", {
* type: "search",
* placeholder: "Enter what pleases you"
* });
@barneycarroll
barneycarroll / mithril-parents.es6
Created December 30, 2016 08:03
Mithril patch which binds a `state.parent` property to nodes referring to the parent `vnode`
import m from 'mithril'
export default ( ...input ) => {
const parent = m( ...input )
return (
parent.children == undefined
? parent
: Object.assign( parent, {
children : children.map( child => Object.assign( child, { parent } ) )
@teknoraver
teknoraver / unixhttpc.go
Last active May 16, 2025 19:35
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@kylemcdonald
kylemcdonald / BluetoothRSSI.m
Created December 14, 2016 21:28
Small command line tool for displaying real time Bluetooth signal strength on a Mac.
// gcc -Wall -o BluetoothRSSI BluetoothRSSI.m -framework Foundation -framework IOBluetooth ; ./BluetoothRSSI
#import <Foundation/Foundation.h>
#import <IOBluetooth/IOBluetooth.h>
int width = 32; // display width in characters
int refresh = 33; // refresh rate milliseconds
int main(int argc, const char * argv[]) {
@autoreleasepool {
@outbreak
outbreak / uuid.js
Created October 25, 2016 17:39
UUID v4 JavaScript implementation with window.crypto.getRandomValues()
function uuid () {
function getRandomSymbol (symbol) {
var array;
if (symbol === 'y') {
array = ['8', '9', 'a', 'b'];
return array[Math.floor(Math.random() * array.length)];
}
array = new Uint8Array(1);
@bisubus
bisubus / ES5-ES6-ES2017-ES2019 omit & pick
Last active April 13, 2024 21:03
ES5/ES6/ES2017/ES2019 omit & pick