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
{ | |
"jwt": { | |
"secret": "&@$!changeme!$@&" | |
} | |
} |
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
"use strict"; | |
const restify = require('restify'); | |
const config = require('./config'); | |
const app = restify.createServer(); | |
app.use(restify.plugins.queryParser()); | |
app.use(restify.plugins.bodyParser()); | |
app.listen(8080, () => { |
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
use rand; | |
use std::fs::File; | |
use display::Display; | |
use keypad::Keypad; | |
pub struct Cpu { | |
program: usize, // program counter starts at 512 bytes | |
opcode: u16, // current opcode | |
stack: [u16; 16], // stack storage |
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
use cpu::Cpu; | |
mod cpu; | |
mod keypad; | |
mod display; | |
fn main() { | |
let mut cpu = Cpu::new(); | |
cpu.load_game("/home/sean/www/chip8-emulator-rust/roms/pong"); |
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
use cpu::Cpu; | |
use display::Display; | |
use keypad::Keypad; | |
pub struct System { | |
cpu: Cpu, | |
memory: [u8; 4096], | |
keypad: Keypad, | |
display: Display | |
} |
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
pub fn load_game(&mut self, game: &str) { | |
// attempt to load supplied ROM | |
let mut reader = File::open(game).expect("Unable to locate ROM"); | |
let mut buffer = Vec::new(); | |
reader.read_to_end(&mut buffer).expect("Unable to read ROM data"); | |
// load ROM into memory (AFTER system reserved memory) | |
for i in 0..buffer.len() { | |
self.memory[i + self.program] = buffer[i]; | |
}; |
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
impl Cpu { | |
pub fn new() -> Cpu { | |
let mut memory = [0; 4096]; | |
// load fonts into memory | |
for i in 0..80 { | |
memory[i] = FONTS[i]; | |
}; | |
Cpu { |
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
$databases['drupal6']['default'] = array( | |
'driver' => 'mysql', | |
'database' => 'database', | |
'username' => 'username', | |
'password' => 'password', | |
'host' => 'hostname', | |
'prefix' => '', | |
); |
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
<?php | |
function import_nodes() { | |
db_query('DELETE FROM {node} WHERE `nid` > 1'); | |
db_query('ALTER TABLE {node} AUTO_INCREMENT = 2'); | |
db_query('DELETE FROM {node_revision} WHERE `nid` > 1'); | |
db_query('ALTER TABLE {node_revision} AUTO_INCREMENT = 2'); | |
db_query('DELETE FROM {field_revision_body} WHERE `entity_id` > 1'); | |
db_query('DELETE FROM {field_data_body} WHERE `entity_id` > 1'); | |
db_query('DELETE FROM {node_comment_statistics} WHERE `nid` > 1'); | |
db_query('TRUNCATE TABLE {url_alias}'); |
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
<?php | |
function handle_pagination($total, $page, $shown, $url) { | |
$pages = ceil( $total / $shown ); | |
$range_start = ( ($page >= 5) ? ($page - 3) : 1 ); | |
$range_end = ( (($page + 5) > $pages ) ? $pages : ($page + 5) ); | |
if ( $page >= 1 ) { | |
$r[] = '<span><a href="'. $url .'">« first</a></span>'; | |
$r[] = '<span><a href="'. $url . ( $page - 1 ) .'">‹ previous</a></span>'; | |
$r[] = ( ($range_start > 1) ? ' ... ' : '' ); |