Skip to content

Instantly share code, notes, and snippets.

View Nasawa's full-sized avatar

Christopher Johnson Nasawa

View GitHub Profile
@Nasawa
Nasawa / cardfarm sockjs onmessage
Created May 20, 2014 03:09
My first sock.js fun
//DEBUG
sock.onmessage = function(message) //When the client hears from the server
{
var msg = JSON.parse(message.data); //parse the JSON object to var msg
try
{
if(msg.name != cName) //if this is for another player
{
if(msg.func == 'updatePosition') //if that player movied
{
@Nasawa
Nasawa / Bruteforce
Last active August 29, 2015 14:01
I was a little to silly to just read this from json...
Crafty.sprite(200, "img/clock.png",
{
clock: [0,0,0,0]
});
Crafty.sprite(128, "img/tiles2.png",
{
grass: [0, 0, 1, 1],
stone: [1, 0, 1, 1],
tilled: [2, 0, 1, 1]
@Nasawa
Nasawa / gs php stuff
Created May 21, 2014 05:04
Just some auth / injection stuff
<?
if ($login)
{
$id = $_SESSION['user'];
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 3600))
{
// last request was more than 30 minutes ago
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
@Nasawa
Nasawa / gssql
Created May 22, 2014 04:19
gs sql query example
<?php
require 'master.php'; //sets obfuscated variables and connections
$userid = $_GET["userid"];
mysqli_query("SET SESSION time_zone = '+00:00'");
$query = "SELECT $dbuserid, $dbcell, ($dbduration - (time_to_sec(CURTIME()) - time_to_sec($dbstart))) as seconds, $dbcount, $dbactive FROM $dbusertable WHERE $dbactive = 0 AND $dbverified = 1 AND $dbclient = 1 AND CURTIME() > $dbstart AND (time_to_sec(CURTIME()) - duration) < time_to_sec($dbstart)";
@Nasawa
Nasawa / 0_reuse_code.js
Created July 18, 2014 23:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public class MyRunnable implements Runnable {
private Data data;
public MyRunnable(Data _data) {
this.data = _data;
}
public void run() {
...
}
}
// show The Image
new DownloadImageTask((ImageView) findViewById(R.id.imageView1))
.execute("http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png");
}
public void onClick(View v) {
startActivity(new Intent(this, IndexActivity.class));
finish();
}
@Nasawa
Nasawa / designer.html
Created August 21, 2014 17:49
designer
<link rel="import" href="../notification-elements/notification-alert.html">
<link rel="import" href="../cool-clock/cool-clock.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
@Nasawa
Nasawa / XMLToTreeNode.cs
Created July 13, 2015 20:28
Convenient way of turning XML into a TreeNode for a Windows Forms TreeView
public static TreeNode ToTreeNode(XmlDocument doc, string root = "root")
{
TreeNode node = new TreeNode(root);
Nodify(node, doc.DocumentElement);
return node;
}
public static TreeNode ToTreeNode(string filename, string root = "root")
{
var x = new XmlDocument();