Skip to content

Instantly share code, notes, and snippets.

View jinhucheung's full-sized avatar
🏗️
Building

jim jinhucheung

🏗️
Building
View GitHub Profile
require 'matrix'
def regression x, y, degree
x_data = x.map {|xi| (0..degree).map{|pow| (xi**pow) }}
mx = Matrix[*x_data]
my = Matrix.column_vector y
((mx.t * mx).inv * mx.t * my).transpose.to_a[0].reverse
end
@quexer
quexer / jQuery-plugin-authoring.md
Created September 4, 2012 09:42
如何编写 jQuery 插件

创建插件


看来 jQuery 你已经用得很爽了,想学习如何自己编写插件。非常好,这篇文档正适合你。用插件和方法来扩展 jQuery 非常强大,把最聪明的功能封装到插件中可以为你及团队节省大量开发时间。

开始

@tomas-stefano
tomas-stefano / Readme.md
Last active January 18, 2023 13:56
Pre commit ruby script

Pre-commit hook

This is a pre-commit script that will see the git diff and run the appropriate checks like JSHint and Rubocop

You can add to your .git/hooks of any repo that you like.

Notes

  1. Don't forget to add the executable permission to this file and have the following installed:
-----BEGIN CERTIFICATE-----
MIIDmDCCAoCgAwIBAgIEaXZGFjANBgkqhkiG9w0BAQsFADB0MQswCQYDVQQGEwJVUzEZMBcGA1UE
CxMQVXNlcm5hbWU6IGJndWVyeTFKMEgGA1UEAwxBXyBETyBOT1QgSU5TVEFMTCB1bmxlc3MgdGhp
cyBpcyB5b3VyIGNlcnRpZmljYXRlIChKTWV0ZXIgcm9vdCBDQSkwHhcNMTUwNjA5MDk0MjM2WhcN
MTUwNjE2MDk0MjM2WjB0MQswCQYDVQQGEwJVUzEZMBcGA1UECxMQVXNlcm5hbWU6IGJndWVyeTFK
MEgGA1UEAwxBXyBETyBOT1QgSU5TVEFMTCB1bmxlc3MgdGhpcyBpcyB5b3VyIGNlcnRpZmljYXRl
IChKTWV0ZXIgcm9vdCBDQSkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC01TE6fnQP
VQtoHyI85tVe5YQzxBsS0ZKwRNr7bWGplku1GOZoSGuR8sgnqiK7vrWk7io6ESbiB8X4EXBSsABR
rkhrwSZINIdAoJ4+ZZVCTDTpxKFXbLbXZze8+xP8PD78HDEr4HxXcbBCAM0W5IwnyfdPMhJQ2ZcF
sE2PfJDHwJ5RJDPXHljZUDhDyu4ZGp5fEt0o6CuDfpOsStcPGiGhcKiXv3vFUN9gEKMATPGLUd8N
@parmentf
parmentf / GitCommitEmoji.md
Last active June 2, 2024 01:20
Git Commit message Emoji
@jonsuh
jonsuh / .bash_profile
Last active February 16, 2024 17:17
Bash echo in color
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
require 'warden/github'
class SidekiqGithubChecker
def self.registered(app)
app.helpers do
def warden; env['warden'] end
def github_organization_authenticate!(name)
unless warden.user.organization_member?(name)
halt [401, {}, ["You don't have access to organization #{name}"]]
end
@onjin
onjin / docker-compose.yml
Created September 5, 2016 09:17
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
@nielsutrecht
nielsutrecht / RsaExample.java
Created December 28, 2016 14:13
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
@480
480 / gist:3b41f449686a089f34edb45d00672f28
Last active May 6, 2024 19:52
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"