Skip to content

Instantly share code, notes, and snippets.

Avatar

Ricky Pai rickypai

View GitHub Profile
View cummlative.sql
SELECT DATE_TRUNC('month', created_at) AS month, sum(count(created_at)) OVER (ORDER BY DATE_TRUNC('month', created_at)) FROM thing GROUP BY DATE_TRUNC('month', created_at);
@rickypai
rickypai / copy_bones.py
Created Jul 10, 2020
Blender copy bones
View copy_bones.py
import bpy
destination_armature = bpy.data.objects['Destination Armature']
destination_root = destination_armature.pose.bones.get("ROOT_GROUND")
source_armature = bpy.data.objects['Source Armature']
source_root = source_armature.pose.bones.get("ROOT_GROUND")
bones = []
View github_go_repository.bzl
load("@bazel_gazelle//:deps.bzl", "go_repository")
# github_go_repository is a wrapper around go_repository to make the fetching of github repos easier
# by converting git clones to http archive downloads. The latter is fast, more reliable, actually
# cachable, and actually recommended by the Bazel team.
# It does have some caveats, so it's not meant to be a complete replacement of `go_repository`.
def github_go_repository(
name,
importpath,
commit,
@rickypai
rickypai / gist:fd577a8f0bfbb19246bff0d497a93239
Created Jun 15, 2019 — forked from technoweenie/gist:1072829
.netrc file so you can push/pull to https git repos without entering your creds all the time
View gist:fd577a8f0bfbb19246bff0d497a93239
machine github.com
login rickypai
password SECRET
machine api.github.com
login rickypai
password SECRET
View isSorted.scala
def isSorted[A](as: Array[A], ordered: (A,A) => Boolean): Boolean = {
def go[A](as: Array[A], ordered: (A, A) => Boolean, acc: Int): Boolean = {
if (acc == 2) {
ordered(as(0), as(1))
} else {
if (ordered(as(acc - 2), as(acc - 1))) {
go(as, ordered, acc - 1)
} else {
false
}
View multi_bazel.md

Managing multiple-versions of Bazel with Homebrew

If you work with multiple repositories that require different versions of Bazel, this guide might help.

Installing a version of Bazel

Homebrew has a mechanism for installing an older version of a particular package. The details are in this Stackoverflow answer for those interested.

The general idea is to find the particular SHA of homebrew-core and install the bazel formula from a particular commit. You can find the history of all Bazel recipe changes in: https://github.com/Homebrew/homebrew-core/commits/master/Formula/bazel.rb.

@rickypai
rickypai / node.rb
Last active Jul 30, 2018
Node formula for 8.11
View node.rb
class Node < Formula
desc "Platform built on V8 to build network applications"
homepage "https://nodejs.org/"
stable do
url "https://nodejs.org/dist/v8.11.3/node-v8.11.3.tar.xz"
sha256 "577c751fdca91c46c60ffd8352e5b465881373bfdde212c17c3a3c1bd2616ee0"
# We track major/minor from upstream Node releases.
# We will accept *important* npm patch releases when necessary.
@rickypai
rickypai / interview.go
Last active May 1, 2018
interview snipplet
View interview.go
package main
import "fmt"
func plusone(a int) int {
return a + 1
}
type testCase struct {
input int
View wtf.rb
# frozen_string_literal: true
module FooFile
class Processor
def self.from_file(file)
new(File.read(file))
end
def initialize(raw)
@raw = raw
View gist:8ef78facff21361509c66e84394ca440
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness
name: liveness-localhost
namespace: cluster-tests
spec:
containers:
- name: liveness
You can’t perform that action at this time.