Skip to content

Instantly share code, notes, and snippets.

@kazuho
kazuho / git-blame-pr.pl
Last active June 28, 2022 07:15
git-blame by PR #
#! /usr/bin/perl
#
# Written in 2017 by Kazuho Oku
#
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#
use strict;
use warnings;
@gbaman
gbaman / HowToOTG.md
Last active June 24, 2024 16:18
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

<?
require("redis.php");
require("json.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));
@motemen
motemen / Ojisan-Patterns.md
Last active March 14, 2021 07:37
おじさんパターン集
  • その面白そうな話、私も参加していいよね?なぜなら私は無条件に受け入れられているからおじさん(闖入おじさん) #おじさんパターン
  • 後出し難癖おじさん #おじさんパターン
  • 困難は成長のチャンス!だから君たちに成長の機会をあげようおじさん (成長おじさん) #おじさんパターン
  • あらゆる事案に一般論コメントおじさん #おじさんパターン
  • 俺ってあらゆることに精通してるじゃん?だから力になるよおじさん (精通おじさん) #おじさんパターン
$ perl installed2cpanfile > cpanfile
$ cpanm --installdeps .
@studio3104
studio3104 / ProvisioningFrameworksCasualTalks01.md
Last active December 16, 2015 10:08
Provisioning Frameworks Casual Talks vol.1

Provisioning Frameworks Casual Talks vol.1

ChefとかPuppetとかの勉強会です
次回があるかはわかりませんが、今回はChef成分多めになっております

インターネット情報

Twitterハッシュタグ #pfcasual
IRCチャンネル #chef-casual@freenode

@tokuhirom
tokuhirom / pbvsp.md
Last active December 15, 2015 15:38
Perl5 Boolean Value Serializer Protocol(PBVSP)

Perl5 Boolean Value Serializer Protocol(PBVSP)

Status

Draft. Plase post a comment on gist.

Why?

Most programming languages have a native Boolean data type. Perl does not.

@mala
mala / gist:5268998
Last active December 15, 2015 13:39
データをpostMessageで受け渡すセッション限りのトークン取得(取得しない)フロー

一瞬popup + 以降iframeでproxyするようなもの。XHR level2いらないのでやや動作環境が広がる。

  • クライアント側ボタンクリックで window.open + ランダムなid(これをclient_id相当にする)の名前をつけてiframe埋め込み
  • popup windowにiframeの名前をpostMessageで送る
  • サーバー側: popup windowはiframeに対してpostMessageで返信(event.source.frames.xxxx)、api-domainのoriginであることを確認、cookieで認証してランダムなidとセットで使えるトークン発行
  • トークン保存はmemcachedなど揮発性のストレージで良い。使っている限り期限が延長される。最長期限があってもよい(あったほうがよい)
  • ログアウトとセットで破棄されるようになっていると良い
  • iframeはポップアップwindowからメッセージを受け取る。ランダムなid + トークンを使ってAPIにアクセスする。
  • iframeは親windowからメッセージを受け取る。あとはpostMessageでproxyしてXHRのリクエスト、レスポンスをやり取りする。
  • iframeは親windowからのメッセージであることをevent.originを使って検証する
@uasi
uasi / Localizable.strings
Created October 9, 2011 08:19
Alternative Japanese localization for Growl 1.3.1
/* No comment provided by engineer. */
"Alert! Enabling this option will add Growl.app to your login items" = "注意!このオプションをオンにすると Growl がログイン項目に追加されます";
/* No comment provided by engineer. */
"Allowing this will let Growl launch everytime you login, so that it is available for applications which use it at all times" = "ログイン時に Growl を起動し、すべてのアプリケーションから使えるようにする";
/* No comment provided by engineer. */
"Application: %@\nTitle: %@\nDescription: %@\nClick to open the log" = "アプリケーション: %1$@\nタイトル: %2$@\n説明: %3$@\nクリックしてログを開く";
/* No comment provided by engineer. */
@yaotti
yaotti / anything-git-project.el
Created December 15, 2010 03:26
List up all files under the control of git and do something (open/view/delete/etc) with them
(defun anything-c-sources-git-project-for (pwd)
(loop for elt in
'(("Modified files (%s)" . "--modified")
("Untracked files (%s)" . "--others --exclude-standard")
("All controlled files in this project (%s)" . ""))
collect
`((name . ,(format (car elt) pwd))
(init . (lambda ()
(unless (and ,(string= (cdr elt) "") ;update candidate buffer every time except for that of all project files
(anything-candidate-buffer))