Skip to content

Instantly share code, notes, and snippets.

View gh640's full-sized avatar
🦔

Goto Hayato gh640

🦔
View GitHub Profile
@gh640
gh640 / Python.sublime-build
Created November 25, 2013 01:19
A sublime text 2 build setting for Python virtualenvwrapper. To use a specific python env for running scripts, it is necessary to get virtualenvwrapper active and environment to switch.
{
// "cmd": ["python", "-u", "$file"],
"shell": true,
"cmd": ["source ~/.bashrc && workon name_of_virtualenv && python -u \"$file\""],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@gh640
gh640 / bookmarklet_to_get_a_link_to_the_page.js
Created November 26, 2013 02:24
bookmarklet to get a link to the page and prompt it. format: <a href="url_of_the_page">title_of_the_page</a>
@gh640
gh640 / widget_of_list_of_related_posts_in_Blogger.html
Last active December 31, 2015 07:39
Blogger で動作する関連記事ウィジェットのための HTML/JavaScript 。 HTML/JavaScript ウィジェットの中にこの全文を書き込んで使います。前提条件:01) jQuery が読み込まれている。02)投稿タイトルのクラス属性が post-title となっている。
@gh640
gh640 / commonElementExist.js
Created December 14, 2013 03:48
JavaScript function to check 2 arrays have any common element or not. return true or false.
// function to check 2 arrays have any common element or not
// @return
// matched : true/false
// @args
// a1 :: array
// a2 :: array
function commonElementExist(a1, a2){
var matched = false;
a1.forEach(function(e1){
if(a2.indexOf(e1) != -1){
@gh640
gh640 / basic_example_for_markdown.md
Created December 15, 2013 11:56
markdown の基本的な記法まとめ。

this is h1

this is h2

this h3

normal paragraph is like this.

unordered list:

@gh640
gh640 / what_methods_python.py
Last active January 1, 2016 04:19
A Python function "what" after Ruby gem "what_methods". "what" function checks all the method of an object and returns the method names which match the expected result. Ruby gem what_methods is here: https://github.com/BMorearty/what_methods
# coding: utf-8
"""
A Python function "what" after Ruby gem "what_methods".
"what" function checks all the method of an object
and returns the method names which match the expected result.
Last updated: 2013/12/23
"""
@gh640
gh640 / PHP.sublime-build
Created January 3, 2014 03:51
Sublime Text 2 PHP build config file to run php scripts on ~/.bashrc setting.
{
// "cmd": ["php", "$file"],
// Enable config in ~/.bashrc
"shell": true,
"cmd": ["source ~/.bashrc && php $file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.php"
}
@gh640
gh640 / widget_of_list_of_related_posts_in_Blogger_by_dl_list.html
Last active August 29, 2015 14:04
Blogger で現在のページの記事の関連記事を定義リストで表示するウィジェットを生成する HTML + JS コード。HTML/JavaScript ウィジェットの中にこの全文を書き込んで使います。前提条件:01) jQuery が読み込まれている。02)投稿タイトルのクラス属性が post-title となっている。
@gh640
gh640 / use_load_multiple_by_role.php
Created February 14, 2015 04:42
Drupal 7 function to get all users with specific role(s)
/**
* get all users with specific role(s)
*
* @param int|int[] $role_id
* role id for role
*
* @return object[]
* user objects with given role(s)
*/
function user_load_multiple_by_role($role_id) {
@gh640
gh640 / phpmd.py
Last active October 4, 2015 04:51
SublimeLinter - phpmd linter file for Sublime Text 2
# coding: utf-8
"""
A phpmd linter for Sublime Text 2.
Since [SublimeLinter-phpmd](https://github.com/SublimeLinter/SublimeLinter-phpmd)
is made only for ST3 and cannot be used for ST2 and I maded this one.
Installation: