Skip to content

Instantly share code, notes, and snippets.

View takamin's full-sized avatar
🏢
In the middle of a dream, I'm still yawning...zzz

Koji Takami takamin

🏢
In the middle of a dream, I'm still yawning...zzz
View GitHub Profile
@takamin
takamin / get-parttial-obj.js
Created February 17, 2022 03:10
JavaScriptのオブジェクトから特定のキーだけを抜き出した別のオブジェクトを作る
/**
* 部分オブジェクトを取り出す。
* @param {string[]} keys 抜き出すキーの配列
* @param {Record<string, any>} obj 元のオブジェクト
* @returns {Record<string, any>} 指定されたキーのオブジェクトを返す(値は共有している)
*/
function getPartialObject(keys, obj) {
return (Object.entries(obj)
.filter(([key]) => keys.includes(key))
.reduce((obj, [key, value]) => {
<Window x:Class="StudyDotNet.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StudyDotNet"
xmlns:vm="clr-namespace:StudyDotNet.ViewModels"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:tr="clr-namespace:StudyDotNet.Triggers"
mc:Ignorable="d"
@takamin
takamin / MainWindow.xaml
Created June 14, 2016 08:40
[WPF/DataGrid] : Binding `DataGridTextColumn.Visibility` to `CheckBox.IsChecked` with a hidden proxy object
<Window x:Class="BindDataGridColumnVisibility.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BindDataGridColumnVisibility"
mc:Ignorable="d"
Title="MainWindow" Height="376" Width="634" WindowState="Maximized">
<Grid>
<Grid.Resources>
@takamin
takamin / jquery_plugin_class.js
Last active August 29, 2015 14:26
ちゃんとしたjQueryプラグインを簡単に作るための関数です。プラグイン個別の機能はクラスに実装してくださいね。
// NAME
//
// jquery_plugin_class - javascriptのクラスをjQueryプラグインとして登録する
//
// DESCRIPTION
//
// クラス名を指定して呼び出せば、そのクラスをjQueryプラグインとして登録します。
// クラスのコンストラクタは、グローバルスコープの関数でないといけません。
// コンストラクタの第1引数には関連するDOM要素が渡されます。
//
@takamin
takamin / daemonize.c
Last active August 29, 2015 14:22
C言語でラズパイのデーモンを作るときの補助関数とスケルトン
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <signal.h>
#include <syslog.h>
static int daemonized = 0; /* daemonized flag */
int daemonize(
const char* pidfilepath,
@takamin
takamin / CMakeLists.txt
Last active August 29, 2015 14:21
ジェネレータの名前に `MinGW` が含まれていたら bar をリンクする CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(hogehoge)
add_executable(hoge hoge.c)
if(CMAKE_GENERATOR MATCHES "MinGW")
target_link_libraries(hoge foo bar)
else()
target_link_libraries(hoge foo)
endif()
@takamin
takamin / pepperTopCamera.py
Last active August 4, 2022 14:43
This is a python 2.7 sample to capture the top camera of Aldebaran robot Pepper or NAO. It displays a image with openCV imshow. Press the [ESC] key to exit the capturing
# vim: set fileencoding=utf-8 :
import sys
import numpy as np
import cv2
from naoqi import ALProxy
if(len(sys.argv) <= 2):
print "parameter error"
print "python " + sys.argv[0] + " <ipaddr> <port>"
sys.exit()
<?php
if(count($argv) != 2) {
exit;
}
$executable_suffixies = array("cmd", "bat", "dll", "exe");
$filename = $argv[1];
$no_suffix = !has_suffix($filename, $executable_suffixies);
$pathes = preg_split('/;/', getenv('PATH'));
foreach( $pathes as $path ) {
echo_file_exists("$path\\$filename");
@takamin
takamin / jquery.uitext.js
Last active August 29, 2015 14:14
the TextBox plugin that utilizes styles jquery-ui.spinner
$.fn.uitext = function() {
this.addClass("ui-spinner-input")
.css({'margin-right':'.4em'})
.appendTo(
$('<span/>')
.addClass("ui-spinner")
.addClass("ui-widget")
.addClass("ui-widget-content")
.addClass("ui-corner-all")
.insertBefore(this));
@takamin
takamin / RFC2822_AddrSpec.class.php
Created February 4, 2015 02:20
Inspection of e-mail addresses based on the specification of the RFC2822 Addr-spec
<?php
/**
* e-mail address specification.
*
* http://blog.livedoor.jp/dankogai/archives/51189905.html
*
* RFC-2822 3.4.1 Addr-spec specification
* https://www.ietf.org/rfc/rfc2822.txt
*/
class RFC2822_AddrSpec {