Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test Page</title>
</head>
<body>
<script type="text/javascript">
var array1 = [1, 2];
Object.defineProperty(Array.prototype, "test", {value : 1,
// $ node rename.js
var fs = require('fs');
var path = '/Users/max/Downloads/test/';
fs.readdir(path, function(err, files) {
files.forEach(function (val, index, array) {
if(val.match(/mp4$/)) fs.renameSync(path + val, path + unescape(val));
});
});
@yoshimax
yoshimax / gist:759432
Created December 30, 2010 03:55
twitter userstream node.js
var oauth = require('oauth-client');
var consumerKey = '',
consumerSecret = '',
oauthToken = '',
oauthTokenSecret = '';
var consumer = oauth.createConsumer(consumerKey, consumerSecret);
token = oauth.createToken(oauthToken, oauthTokenSecret);
signer = oauth.createHmac(consumer, token);
@yoshimax
yoshimax / gist:1059875
Created July 2, 2011 09:02
Progression SerialList
var list:SerialList = new SerialList();
for (var i:int = 1; i<=3; i++) {
var className:String = "Item" + i + "Btn";
var customClass:Class = getDefinitionByName( className ) as Class;
itemsArray[i] = new customClass();
list.addCommand( new AddChild(container, itemsArray[i]) );
}
list.execute();
@yoshimax
yoshimax / gist:2694116
Created May 14, 2012 13:54
sharedDispatcher is deprecated
// http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:migrate_to_v2.0#ccdirector
// CCTouchDispatcher
// v1.0
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self
priority:0
swallowsTouches:YES];
// v2.0
@yoshimax
yoshimax / gist:2726980
Created May 18, 2012 18:48
shouldAutorotateToInterfaceOrientation
// http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:migrate_to_v2.0#ccdirector
// cocos2d v2.0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"interfaceOrientation: %d", interfaceOrientation);
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
{
#include <Wire.h>
#include "BlinkM_funcs.h"
#define blinkm_addr 0x00
int val;
void setup(){
Serial.begin(9600);
pinMode(13,OUTPUT);
@yoshimax
yoshimax / BLE Shield + BlinkM
Created May 5, 2013 00:09
Arduino BLEShield SDK Chat_Sketch Text send 'r' BlinkM fade to 'Red' Sketch https://github.com/RedBearLab/Release/tree/master/BLEShield
#include <Arduino.h>
#include <SPI.h>
#include "ble.h"
#include <Wire.h>
#include "BlinkM_funcs.h"
#define blinkm_addr 0x00
#include <Arduino.h>
#include <SPI.h>
#include "ble.h"
#include <Wire.h>
#include "BlinkM_funcs.h"
// blinkM
#define blinkm_addr 0x00
@yoshimax
yoshimax / gist:6972474
Created October 14, 2013 08:10
Inset for iOS7
- (void)orientationChanged:(NSNotification *)notification {
NSLog(@"%s", __func__);
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
float statusBarHeight = (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) ? statusBarViewRect.size.width : statusBarViewRect.size.height;
float heightPadding = statusBarHeight + self.navigationController.navigationBar.frame.size.height;
[self.tableView setContentInset:UIEdgeInsetsMake(heightPadding, self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right)];
}