This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table'; | |
class Table extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
var products = [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer