Skip to content

Instantly share code, notes, and snippets.

View 1uokun's full-sized avatar
🤙
always-online, part-time job contract me

罗坤 1uokun

🤙
always-online, part-time job contract me
View GitHub Profile
@getify
getify / ex1-prototype-style.js
Last active January 7, 2024 11:58
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
@LiuJi-Jim
LiuJi-Jim / bezier.js
Last active July 12, 2020 06:17
De Casteljau Bezier
function DeCasteljauBezier(points, density, step){
//if (points.length < 3) return null;
console.time('bezier');
var ps = points.map(function(p){
return {
x: p.x,
y: p.y
};
}),
results = [],
@chenwery
chenwery / iframeclick.js
Created February 20, 2014 06:21
javascript:监听页面中iframe被点击
var IframeOnClick = {
resolution : 200,
iframes : [],
interval : null,
Iframe : function() {
this.element = arguments[0];
this.cb = arguments[1];
this.hasTracked = false;
},
track: function(element, cb) {
@rjchatfield
rjchatfield / functors.js
Created February 1, 2015 13:52
Maybe, Either & Try Functors in ES6
//--
//-- FUNCTORS in ES6
//--
//-- BOILER PLATE
let fmap = (f) => (functor) => functor.map(f);
let c2 = (f2, f1) => (x) => f2(f1(x));
let c3 = (f3, f2, f1) => (x) => f3(f2(f1(x)));
@RavenHursT
RavenHursT / url-extract-root-domain.js
Created February 23, 2015 22:58
Javascript extract root domain from URL
var extractRootDomain = function(url){
return url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)[1].split('.').slice(-2).join('.');
};
@acdlite
acdlite / flux.js
Last active October 7, 2021 17:19
A Redux-like Flux implementation in <75 lines of code
/**
* Basic proof of concept.
* - Hot reloadable
* - Stateless stores
* - Stores and action creators interoperable with Redux.
*/
import React, { Component } from 'react';
export default function dispatch(store, atom, action) {
@varemenos
varemenos / 1.README.md
Last active October 23, 2024 13:07
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@tatocaster
tatocaster / RealPathUtil.java
Last active October 25, 2024 07:18
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@brucetoo
brucetoo / IdentifierUtil.java
Created December 7, 2015 10:34
通过资源名获取资源ID
package com.netease.cc.mgsdk.util;
import java.lang.reflect.Field;
import android.app.Activity;
import android.content.Context;
import android.view.View;
public class IdentifierUtil {
/**
@esamattis
esamattis / WebViewAutoHeight.js
Last active February 11, 2022 16:01
React native: Is it possible to have the height of a html content in a webview? http://stackoverflow.com/q/32952270
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2016 Esa-Matti Suuronen <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.