Skip to content

Instantly share code, notes, and snippets.

View kindy's full-sized avatar

Kindy Lin kindy

  • Beijing, China
  • 16:38 (UTC +08:00)
  • LinkedIn in/kindy
View GitHub Profile
@kindy
kindy / README.md
Created April 4, 2018 02:04 — forked from MoOx/README.md
How to keep in sync your Git repos on GitHub, GitLab & Bitbucket easily
title tags authors
How to keep in sync your Git repos on GitHub, GitLab & Bitbucket easily
git
github
gitlab
bitbucket
MoOx
@kindy
kindy / raytracer.ts
Created February 21, 2018 07:15
AST Play assets
class Vector {
constructor(public x: number, public y: number, public z: number) { }
static times(k: number, v: Vector) {
return new Vector(k * v.x, k * v.y, k * v.z);
}
static minus(v1: Vector, v2: Vector) {
return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
@kindy
kindy / emojis.js
Created December 25, 2017 07:54
emojis in js
const emojis = [
0x1f201,
0x1f202,
0x1f21a,
0x1f22f,
0x1f232,
0x1f233,
0x1f234,
0x1f235,
0x1f236,
@kindy
kindy / get-copyright.js
Created July 10, 2017 15:17
get copyright

Google Apps Script Document Utilities

  • getAllLinks.js

  • getAllLinks(element) - returns array of all UrlLinks in Document

  • findAndReplaceLinks(searchPattern,replacement) - changes all matching links in Document

  • changeCase.js - Document add-in, provides case-change operations in the add-in Menu.

  • onOpen - installs "Change Case" menu

  • _changeCase - worker function to locate selected text and change text case. Case conversion is managed via callback to a function that accepts a string as a parameter and returns the converted string.

  • helper functions for five cases

@kindy
kindy / group_vars
Created February 24, 2016 06:30 — forked from charypar/group_vars
Deploying SSL keys securely with Ansible (code)
---
ssl_certificates:
- certificate_src: secure.example.com.pem
certificate_dest: /etc/ssl/certs/secure.example.com.pem
key_src: secure.example.com.protected.key
key_dest: /etc/ssl/private/secure.example.com.protected.key
key_stripped: /etc/ssl/private/secure_example.com.key
key_password: "{{ssl_passphrase}}"
@kindy
kindy / ga-get-client-id.js
Created November 30, 2015 04:29
How analytics.js generate client id
// http://stackoverflow.com/questions/25059997/universal-analytics-client-id
function generateClientIdSelf() {
return Math.floor(Math.random() * 0x7FFFFFFF) + "." + Math.floor(Date.now() / 1000);
}
// https://www.google-analytics.com/analytics.js
function generateClientIdGA() {
function hd() {
return math.round(2147483647 * math.random());
}
@kindy
kindy / views.py
Created October 13, 2015 07:16
django-kext
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.http import Http404
from django.http import JsonResponse, HttpResponseRedirect, HttpResponsePermanentRedirect
from django.http import HttpResponseBadRequest, HttpResponseForbidden
from django.views.generic import TemplateView
from django.utils.decorators import method_decorator
from threading import local
class Bucket(object):
def __init__(self, bucket, s3=None):
if s3 is None:
s3 = s3_storage
self.bucket = bucket
self.s3 = s3
@kindy
kindy / example.com
Last active August 29, 2015 14:27 — forked from mignev/example.com
Django deployment with Nginx and Tornado Web
upstream tornadoFrontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;