Skip to content

Instantly share code, notes, and snippets.

View zcaudate's full-sized avatar

Chris Zheng zcaudate

View GitHub Profile
@Zejnilovic
Zejnilovic / buildHadoopNativeLibraries.sh
Created May 20, 2019 15:32
A script to build and use Hadoop Native libraries on Mac
# !!CHANGE THIS!!
HVERSION=2.7.5
#!! AND LET IT RUN
brew install gcc autoconf automake libtool cmake snappy gzip bzip2 zlib openssl
cd ~
mkdir -p tmp
cd ~/tmp
@beders
beders / mini-promise.cljc
Last active January 26, 2022 22:18
Super minimal macro to simplify dealing with promise/async/await code in ClojureScript
(defn create-function-call [param expr]
"Create an sexp for calling expr with a first argument provided by a promise.
If expr is a list (already in form suitable for a function call), insert the first argument at second position,
otherwise turn expr into a function call expression, unless the function is an fn, which is simply returned.
println -> (fn [param] (println param))
(* 2) -> (fn [param] (* param 2))
@dorelljames
dorelljames / letsencrypt-guide-nginx-acme.sh.md
Last active November 13, 2024 22:47
SSL via Let's Encrypt (nginx server)

Nginx SSL via Let's Encrypt and acme.sh

This guide is intended to walk you through installation of a valid SSL on your server for your site at example.com. This example is using root user, you may need to use sudo if you encounter problems such as write permissions.

Pre-requisites

  • Install acme.sh on your server. This will create a acme.sh folder in your home directory and more importantly create an everyday cron job to check and renew certificates if needed.
  • Install nginx server (different per distibution so just make sure you have it up and running)
@huxuan
huxuan / Makefile
Last active February 26, 2023 17:33
Hello World for LuaJIT FFI/C++ binding.
all: lib run
lib:
g++ -shared -fPIC -o libhello.so libhello.cpp hello.cpp
run:
luajit main.lua
clean:
rm *.so
@apangin
apangin / HotSpot JVM intrinsics
Last active October 29, 2024 15:13
HotSpot JVM intrinsics
_hashCode java/lang/Object.hashCode()I
_getClass java/lang/Object.getClass()Ljava/lang/Class;
_clone java/lang/Object.clone()Ljava/lang/Object;
_dabs java/lang/Math.abs(D)D
_dsin java/lang/Math.sin(D)D
_dcos java/lang/Math.cos(D)D
_dtan java/lang/Math.tan(D)D
_datan2 java/lang/Math.atan2(DD)D
_dsqrt java/lang/Math.sqrt(D)D
_dlog java/lang/Math.log(D)D
@jukworks
jukworks / shared-secret.clj
Created October 8, 2013 09:50
A sample code for "Shamir's secret sharing" (http://goo.gl/7PjHF) with the Lagrange interpolation. Written in Clojure.
;; to represent a polynomial, a vector [a b c d] means a + bx + cx^2 + dx^3
;; gen-poly makes a polynomial with n random coefficients (max value: max-coeff)
(defn gen-poly [n max-coeff]
(vec (repeatedly n #(rand-int max-coeff))))
;; if p is negative, returns n
;; else returns n mod p
(defn modp [n p]
(if (<= p 0)
n
@foxbunny
foxbunny / pyproto.py
Created November 25, 2012 05:01
Prototypal object model in Python (sort of)
""" https://bitbucket.org/brankovukelic/pyproto """
from copy import copy
__all__ = ['Object']
class Object(object):
"""Base prototype for prototypal object model in Python
To create a new object, simply instantiate an Object instance::
@inflammable
inflammable / base58.js
Created June 14, 2012 09:50
Base58 (and other) Encoding and Decoding in Javascript
/*
* base58.js
* - encodes integers to and decodes from a base58 (or your own) base58 alphabet
* - based on Flickr's url shortening
*
* usage:
* base58.encode(integer);
* base58.decode(string);
*
* (c) 2012 inflammable/raromachine
@Chase-san
Chase-san / Rabbit.java
Last active August 28, 2024 23:57
Rabbit Stream Cipher
package org.csdgn.crypt;
import java.util.Arrays;
/**
* Tested against the actual RFC.
*
* @author Chase (Robert Maupin)
* @see {@link http://tools.ietf.org/rfc/rfc4503.txt}
*/
@joelnet
joelnet / example.html
Created June 3, 2011 18:03
Unobtrusive Knockout support library for jQuery
Choose a ticket class: <select id="tickets"></select>
<p id="ticketOutput"></p>
<script id="ticketTemplate" type="text/x-jquery-tmpl">
{{if chosenTicket}}
You have chosen <b>${ chosenTicket().name }</b>
($${ chosenTicket().price })
<button data-bind="click: resetTicket">Clear</button>
{{/if}}