Skip to content

Instantly share code, notes, and snippets.

@n0nick
n0nick / index.ts
Last active December 18, 2017 23:31
class A {
private foo;
private bar;
func() {
console.log({
a: () => { console.log(this.foo); }, // this is fine
b() { console.log(this.bar); }, // here's the bug
});
}
@n0nick
n0nick / .prettierrc
Last active September 26, 2017 09:45
ale-example
{
"singleQuote": true,
}
@n0nick
n0nick / test.js
Created September 24, 2017 05:22
Adding gem paths to Webpacker config
// config/webpack/test.js
const environment = require('./environment');
const webpackConfigWithGems = require('./utils/webpack_config_with_gems');
module.exports = webpackConfigWithGems(environment);
@n0nick
n0nick / copy_gem_assets_plugin.js
Last active June 25, 2017 05:24
Webpack plugin for copying JS assets from Ruby gems (in a Webpacker/Rails project)
// config/webpack/plugins/copy_gem_assets_plugin.js
const copy = require('copy');
const path = require('path');
const { execSync } = require('child_process');
const { settings } = require('../configuration.js');
function CopyGemAssetsPlugin(options) {
this.gemsList = options.gems || [];
this.outPath = options.outPath || path.join('vendor', 'gems');
}
@n0nick
n0nick / kube-context.zsh
Created January 25, 2017 10:57
Kubernetes context selector (with ZSH completions)
# kubectl context switcher + completion
function kube-context() {
kubectl config use-context $@
}
_kube-context_completions() {
local -a options
options=()
for c in $(kubectl config view -o jsonpath='{.contexts[*].name}'); do
d=$(echo $c | awk 'BEGIN { FS="_" }; { printf "%11s: %-15s %-14s", $4, $3, $2 }')

Keybase proof

I hereby claim:

  • I am n0nick on github.
  • I am n0nick (https://keybase.io/n0nick) on keybase.
  • I have a public key whose fingerprint is F978 9870 5D9C 85EE B809 30B6 14BE 250B 5830 BDFB

To claim this, I am signing this object:

Image: /Users/sagie/Downloads/53f770fc-4ce1-11e5-9afe-a822d4863969.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 200x200+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
@n0nick
n0nick / ask.sh
Last active August 29, 2015 14:20
General purpose bash ask prompt
# Usage:
# ask "What's up?" answer "ok"
# echo $answer
ask() {
local question=$1
local default=$3
local resultvar=$2
echo -n "$question "
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
class ApplicationController < ActionController::Base
def redirect_to_index
redirect_to(:action => :index)
end
end
describe ApplicationController, :type => :controller do
def score(dice)
dice.sort.each_slice(3).inject(0) do |score, slice|
score +
if slice.count(slice.first) == 3
slice[0] == 1 ? 1000 : slice[0] * 100
else
slice.inject(0) do |slice_score, num|
slice_score + (num == 1 ? 100 : num == 5 ? 50 : 0)
end
end