Skip to content

Instantly share code, notes, and snippets.

View hkondo's full-sized avatar

Hideki KONDO hkondo

  • Kanda University of Internaional Studies
  • Wakana 1-4-1, Mihama, Chiba, JAPAN
View GitHub Profile
@hkondo
hkondo / sync.html
Created December 21, 2014 12:40
Synchronized TextArea
<script>
function sync() {
var m = document.getElementById("main");
var s = document.getElementById("sub");
s.value = m.value;
window.setTimeout( function() {
s.focus();
s.selectionStart = m.selectionStart;
s.selectionEnd = m.selectionEnd;
@hkondo
hkondo / MultiSessionScripting
Created August 15, 2014 04:45
JavaScript in Java, multiple sessions.
import javax.script.*;
public class Script
{
public static void main(String args[])
{
ScriptEngineManager m = new ScriptEngineManager();
Session s1 = new Session(m);
Session s2 = new Session(m);
# Configuring Tagged-VLAN on Cisco 2960 series.
C2960S-02#conf t
Enter configuration commands, one per line. End with CNTL/Z.
C2960S-02(config)#interface gigabitethernet0/1
C2960S-02(config-if)#switchport mode access
C2960S-02(config-if)#switchport access vlan 2000
C2960S-02(config-if)#end
@hkondo
hkondo / vlccap.sh
Created June 24, 2014 01:22
Capture from WebCamera with VLC
/Applications/VLC.app/Contents/MacOS/VLC --intf=dummy "http://camadmin:[email protected]/nphMotionJpeg?Resolution=640x480&Quality=Clarity&Framerate=30" --sout=file/raw:/Path/To/Dir/hogehoge.raw
@hkondo
hkondo / multipart-cutter.rb
Created June 23, 2014 23:46
Extract files from multipart.
boundary='--myboundary'
ct = 'Content-type:'
cl = 'Content-length:'
no = 1
File.open(ARGV[0], 'r'){|f|
while(true)
length = 0
# skip to boundary.
@hkondo
hkondo / capture.m
Created June 23, 2014 22:23
Capturing displays into PNG on OS X
void capture(int dispId) {
NSLog(@"Start capturing.");
CGImageRef imageRef = CGDisplayCreateImage(dispId);
NSLog(@"End");
NSURL *fileURL = [NSURL fileURLWithPath:[@"~/Desktop/screenshot.png" stringByExpandingTildeInPath]];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)fileURL, kUTTypePNG , 1, NULL);
CGImageDestinationAddImage(destination, imageRef, NULL);
@hkondo
hkondo / CGDisplayCreateImage.m
Created June 14, 2014 22:31
Capture Screen Images
//
// main.m
// Screenshot
//
// Created by Hideki KONDO on 2014/06/14.
// Copyright (c) 2014年 Hideki KONDO. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
/*
* glGrab.c
* Found in http://lists.apple.com/archives/cocoa-dev/2005/Aug/msg00901.html
* Line 186 has a fix for Intel processors: http://lists.apple.com/archives/quartz-dev/2006/May/msg00100.html
*/
/*
IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
consideration of your agreement to the following terms, and your use, installation or modification
of this Apple software constitutes acceptance of these terms. If you do not agree with these terms,
@hkondo
hkondo / enable_screen_sharing.sh
Last active August 29, 2015 14:02
The way to enable screen sharing from the command line. This enables only Screen Sharing, not Remote Management.
# http://pivotallabs.com/enabling-os-x-screen-sharing-from-the-command-line/
sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
sudo launchctl load /System/Library/LaunchDaemons/com.apple.screensharing.plist