Skip to content

Instantly share code, notes, and snippets.

View jugyo's full-sized avatar
🏠
Working from home

Kaz jugyo

🏠
Working from home
  • The League
  • New Jersey
View GitHub Profile
@jugyo
jugyo / index.js
Last active November 26, 2020 04:34
An example to send email with Cloud Pub Sub and Cloud Functions #Rails
const sendEmail = require('./sendEmail').sendEmail;
/**
* Deplooyment:
*
* $ gcloud beta functions deploy sendEmail --trigger-topic sendEmail
*
*/
/**
@jugyo
jugyo / file_name_on_status_bar.py
Created February 26, 2013 07:41
Sublime Text Plugin to show file name on status bar
import sublime_plugin
class FileNameOnStatusBar(sublime_plugin.EventListener):
def on_activated(self, view):
path = view.file_name()
if path:
for folder in view.window().folders():
path = path.replace(folder + '/', '', 1)
view.set_status('file_name', path)
else:
@jugyo
jugyo / sublime_text_2_plugin_tips.md
Created August 13, 2012 09:54
Sublime Text 2 Plugin Tips

Sublime Text 2 Plugin Tips

API Reference

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

view.run_command('example')
@jugyo
jugyo / look.rb
Created March 23, 2012 05:19
earthquake.gem look plugin
# 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"
#!/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 February 27, 2018 17:13
React functional component with withStyles
// <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 February 20, 2012 15:06
webmock + sinatra
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'
...
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) {
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 July 19, 2019 18:57
Model class with PouchDB
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"}