Skip to content

Instantly share code, notes, and snippets.

View vinnyoodles's full-sized avatar
🏡
Working from home

Vincent Le vinnyoodles

🏡
Working from home
View GitHub Profile
@vinnyoodles
vinnyoodles / AppDelegate.swift
Last active June 20, 2016 16:14
DualSlideMenuViewController: refresh on action
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let defaults = NSUserDefaults.standardUserDefaults();
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
storyboard = UIStoryboard(name: "Main", bundle: nil)
let leftView = storyboard?.instantiateViewControllerWithIdentifier("LeftMenuController")
let rightView = storyboard?.instantiateViewControllerWithIdentifier("RightMenuController")
import React from 'react';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
class Table extends React.Component {
constructor(props) {
super(props);
}
render() {
var products = [
{
@vinnyoodles
vinnyoodles / server.js
Last active December 25, 2016 03:44
React Native Socket.io Initial Server
var express = require('express');
var http = require('http')
var socketio = require('socket.io');
var app = express();
var server = http.Server(app);
var websocket = socketio(server);
server.listen(3000, () => console.log('listening on *:3000'));
// The event will be called when a client is connected.
@vinnyoodles
vinnyoodles / client.js
Created December 25, 2016 03:44
React Native Socket.io Initial Client
import React from 'react';
import SocketIOClient from 'socket.io-client';
class Main extends React.Component {
constructor(props) {
super(props);
// Creating the socket-client instance will automatically connect to the server.
this.socket = SocketIOClient('http://localhost:3000');
}
@vinnyoodles
vinnyoodles / user.js
Created December 25, 2016 04:21
React Native Socket.io User
// Client side
determineUser() {
AsyncStorage.getItem('userId')
.then((userId) => {
if (userId) {
this.socket.emit('i-dont-need-an-id');
} else {
this.socket.emit('i-need-id');
this.socket.on('here-is-your-id', (id) => {
AsyncStorage.setItem('userId', id);
@vinnyoodles
vinnyoodles / broadcast.js
Last active December 25, 2016 04:26
React Native Socket.io Broadcast Message
// Server side
socket.on('message', (message) => {
// Save the message document in the `messages` collection.
db.collection('messages').insert(message);
// The `broadcast` allows us to send to all users but the sender.
socket.broadcast.emit('message', message);
});
// Client side
@vinnyoodles
vinnyoodles / message.js
Created December 25, 2016 04:24
React Native Socket.io Existing Messages
socket.on('connection', () => {
var messages = db.collection('messages').find({
chatId: chatId // We want all the messages for that room.
}).sort({
createdAt: -1 // It's best not to assume that it is in order.
});
socket.emit('message', messages);
});
@vinnyoodles
vinnyoodles / kmp.java
Created December 30, 2016 22:30
Knuth Morris Pratt string searching algorithm in Java
import java.util.Scanner;
public class KMP {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String search = kb.next();
String target = kb.next();
int result = KMP(search, target);
if (result == -1) {
System.out.println("NO");
#!/bin/bash
echo "Compiling source code"
javac ../src/Minor/P2/DS/BST.java
mv ../src/Minor/P2/DS/*.class Minor/P2/DS
java -jar BSTGenerator.jar
echo "Running test"
java testDriver
@vinnyoodles
vinnyoodles / test.sh
Created April 21, 2017 00:07
Graph Shell Script
#!/bin/bash
echo "Compiling source code"
javac SSAD.java
echo "Running test"
for i in `seq 1 1 $1`; do
java -jar SSADGen.jar Graph${i}.txt profResults${i}.txt
java SSAD Graph${i}.txt log${i}.txt