Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
😐

Kaz jugyo

💭
😐
  • MUA inc.
  • New York
View GitHub Profile
@jugyo
jugyo / sublime_text_2_plugin_tips.md
Created Aug 13, 2012
Sublime Text 2 Plugin Tips
View sublime_text_2_plugin_tips.md

Sublime Text 2 Plugin Tips

API Reference

コマンドの実行はコンソール( ctrl + ` で開ける)で以下を実行する:

view.run_command('example')
@jugyo
jugyo / look.rb
Created Mar 23, 2012
earthquake.gem look plugin
View look.rb
# coding: UTF-8
require 'active_support/core_ext/hash'
Earthquake.init do
command :look do |m|
args = m[1].split(/\s+/)
slop = Slop.new(:strict => true)
slop.banner "Usage: :look user_name or image_url"
View ggrep
#!/bin/bash
# NOTE: based on a snippet found in somewhere in Stack Overflow
find . -type d -name .git -maxdepth 2 | while read line; do
(
cd $line/..
cwd=$(pwd)
echo "$(tput setaf 2)$cwd$(tput sgr0)"
git --no-pager grep -n -- "$@"
@jugyo
jugyo / Foo.js
Created Feb 27, 2018
React functional component with withStyles
View Foo.js
// <Foo onClick={this.handleClick} />
const Foo = withStyles((theme) => ({
foo: {
color: 'red',
},
}))((props) => {
const { classes, onClick } = props
return (
<div onClick={onClick} className={classes.foo}>
@jugyo
jugyo / gist:1869594
Created Feb 20, 2012
webmock + sinatra
View gist:1869594
require 'webmock'
require 'sinatra/base'
WebMock::API.stub_request(:any, /www\.example\.com/).to_rack(Class.new(Sinatra::Base) {
post "/foo" do
"FOO"
end
})
require 'httpclient'
View app.module.ts
...
export class AppModule {
constructor(router: Router, viewportScroller: ViewportScroller) {
router.events.pipe(filter((e) => e instanceof Scroll)).subscribe((e: any) => {
if (e.position) {
// backward navigation
setTimeout(() => {
viewportScroller.scrollToPosition(e.position);
}, 100);
} else if (e.anchor) {
View verify-github-webhook.ts
const crypto = require("crypto")
export function verifyGithubWebhook(payload: string, signature: string, secret: string) {
const hmac = crypto.createHmac("sha1", secret)
hmac.update(JSON.stringify(payload))
const calculatedSignature = "sha1=" + hmac.digest("hex")
const valid = crypto.timingSafeEqual(Buffer.from(calculatedSignature), Buffer.from(signature))
if (!valid) {
throw new Error("Invalid github webhook call")
}
@jugyo
jugyo / Main.js
Last active Jul 19, 2019
Model class with PouchDB
View Main.js
export default class User extends Model {
static className = 'User'
}
await User._put({id: 1, name: 'Jugyo'})
await User.get(1) // {className: "User", id: 1, name: "Jugyo", _id: "User-1", _rev: "1-b2d6c93292974cd1b14a786f7576ec53"}
View hyphenate
#!/bin/sh
echo $* | awk '{ gsub(/[^A-Za-z]+/, "-"); print tolower($0) }'
View DomainMapping.yaml
# Depends on App
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An example SAM template for Lambda Safe Deployments.
Parameters:
DomainName:
Type: String
CertificateArn: