Skip to content

Instantly share code, notes, and snippets.

View mralexgray's full-sized avatar

Alex Gray mralexgray

View GitHub Profile
@mralexgray
mralexgray / nodobjc.blocks.coffee
Last active December 15, 2015 04:49 — forked from thomaswrenn/index.js
NodObjC works with ObjC Blocks
$ = require 'nodobjc'
$.import 'Foundation'
$.NSAutoreleasePool 'new'
randChar = -> $(String.fromCharCode Math.round(Math.random() * 26) + 'a'.charCodeAt 0 )
array = $.NSMutableArray 'new'
array 'addObject', randChar() for i in [1..10]
@mralexgray
mralexgray / .gitignore
Created December 12, 2015 01:59 — forked from TooTallNate/.gitignore
low-level objc runtime apis
*
!*.m
!Makefile
@mralexgray
mralexgray / ORSSerialPort+Attributes.m
Created December 1, 2015 21:42 — forked from armadsen/ORSSerialPort+Attributes.m
Example code to get USB device properties for a given instance of ORSSerialPort. Will only work for USB-to-serial adapters, not internal serial ports. Based on https://gist.github.com/rhwood/4124251.
#import <Foundation/Foundation.h>
#import <IOKit/usb/USBSpec.h>
#import "ORSSerialPort.h"
@interface ORSSerialPort (Attributes)
@property (nonatomic, readonly) NSDictionary *ioDeviceAttributes;
@property (nonatomic, readonly) NSNumber *vendorID;
@property (nonatomic, readonly) NSNumber *productID;
html ->
head ->
title "ToDoNe"
link href: "/stylesheets/app.css", media: "all", rel: "stylesheet", type: "text/css"
for file in ['json2', 'jquery-1.5', 'underscore-1.1.6', 'backbone'] #, 'backbone-localstorage']
script type: "text/javascript", src: "/javascripts/#{file}.js"
script src: "/javascripts/client.js"
body ->
@mralexgray
mralexgray / index.js
Created October 14, 2015 04:02 — forked from iamnoah/index.js
Simple node.js webserver with logging. Serves whatever files are reachable from the directory where node is running.
/*
* Copyright (c) 2010 Noah Sloan <http://noahsloan.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@mralexgray
mralexgray / shell.variable.substitution.js
Created September 24, 2015 21:17
shell variable substitution
var AsciiTable = require('ascii-table')
var sys = require('sys')
var _ = require('underscore')
var exec = require('child_process').execSync
function err (message) {
console.info('error:' + message);
}
function puts(error, stdout, stderr) {
#include <ESP8266WiFi.h>
const char* ssid = "yourSsid";
const char* password = "yourPassword";
String readStrings = ""; // สร้างตัวแปรมาเก็บข้อมูลค่าที่ส่งเข้ามา
int pin1 = 14; //กำหนด GPIO 14 (D5)
int pin2 = 12; //กำหนด GPIO 12 (D6)
int pin3 = 13; //กำหนด GPIO 13 (D7)
@mralexgray
mralexgray / argparse.zsh
Last active August 29, 2015 14:25
Canonical shell argument parsing.
#!/usr/bin/env zsh
# Print usage information if there are no arguments on the command line.
[ "$#" = "0" ] &&
echo 'Usage: via-ssh.sh [ -v ] [ -d ] [USER@]SERVER[:PORT]' && exit 1
# Process the command line parameters.
while [ "$#" != '0' ] ; do
case "$1" in
-v) VERBOSE=1 ; shift ;;
@mralexgray
mralexgray / via-ssh.sh
Last active August 29, 2015 14:25 — forked from vitex/via-ssh.sh
#!/bin/sh
########################################################################
#
# Usage: via-ssh.sh [-v] [-d] [USER@]SERVER[:PORT]
#
# -v Provide verbose output.
# -d Send all UDP on the DNS port 53 to 127.0.0.1.
# USER User name to use for SSH; default is current user.
# SERVER Server to use for SSH.
@mralexgray
mralexgray / advcpmv-8.23_0.5.5.patch
Created July 9, 2015 13:48
'cp' and 'mv' utilities with progress bar patches
diff -rup coreutils-8.23/src/copy.c coreutils-8.23-patched/src/copy.c
--- coreutils-8.23/src/copy.c 2014-07-13 16:09:52.000000000 -0600
+++ coreutils-8.23-patched/src/copy.c 2015-04-11 16:15:00.000000000 -0600
@@ -113,6 +113,71 @@ struct dir_list
dev_t dev;
};
+struct progress_status {
+ int iCountDown;
+ char ** cProgressField;