Skip to content

Instantly share code, notes, and snippets.

@alansparrow
alansparrow / ChatProgram.java
Created April 14, 2014 19:08
Simple Chatting Program using RS-232
package com.alansparrow.chat;
import gnu.io.CommPortIdentifier;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import gnu.io.UnsupportedCommOperationException;
import java.io.IOException;
@alansparrow
alansparrow / facebook.c
Created April 29, 2014 16:30
iOS facebook share
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[facebookSheet setInitialText:@"Facebooking from my own app: http://www.google.com! :)"];
NSString *gameURL = @"http://www.google.com";
[facebookSheet addURL:[NSURL URLWithString:gameURL]];
[[CCDirector sharedDirector] presentViewController:facebookSheet animated:NO completion:nil];
NSLog(@"Twitter1");
}
@alansparrow
alansparrow / twitter.c
Created April 29, 2014 16:31
iOS twitter share
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Tweeting from my own app: http://www.google.com! :)"];
NSString *gameURL = @"http://www.google.com";
[tweetSheet addURL:[NSURL URLWithString:gameURL]];
[[CCDirector sharedDirector] presentViewController:tweetSheet animated:NO completion:nil];
NSLog(@"Twitter1");
}
@alansparrow
alansparrow / social.c
Created April 29, 2014 16:32
Social sharing
NSString *text = @"This game will help you fall asleep ^.^";
NSURL *url = [NSURL URLWithString:@"https://twitter.com/AlanSparrow9"];
NSArray *objectsToShare = @[text, url];
UIActivityViewController *controller = [[UIActivityViewController alloc]
initWithActivityItems:objectsToShare
applicationActivities:nil];
controller.excludedActivityTypes = @[UIActivityTypeAssignToContact];
@alansparrow
alansparrow / incredible eggs
Created April 30, 2014 00:34
story incredible eggs
Want a game to help you sleep? This is your game! You will save these beautiful eggs by make the jump ^.^ Don't let the fox eat them!
"Long long time ago, on the planet named B-181, there is a fox prince. The planet is so small that it will blow off if there are many eggs. For the fox prince so loved his little world that he keep eating all the eggs, that whoever jump will not be eaten..."
@alansparrow
alansparrow / openwrt wireless
Created May 7, 2014 05:17
OpenWrt Wireless
rm /etc/config/wireless
wifi detect > /etc/config/wireless
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
@alansparrow
alansparrow / add button.m
Created May 7, 2014 09:42
add button to view cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Configure the cell...
// add friend button
UIButton *addFriendButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
addFriendButton.frame = CGRectMake(200.0f, 5.0f, 75.0f, 30.0f);
[addFriendButton setTitle:@"Add" forState:UIControlStateNormal];
[cell addSubview:addFriendButton];
@alansparrow
alansparrow / B-Tree.c
Last active August 29, 2015 14:01
My implementation of B-Tree
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
typedef enum { FALSE, TRUE } boolean;
#define MAX_KEY 3 //511
#define B_TREE_T 2 //256
typedef struct Key
@alansparrow
alansparrow / openwrtwifi
Created May 14, 2014 08:14
Openwrt wifi
Install kmod-ath9k and:
rm /etc/config/wireless
wifi detect > /etc/config/wireless