Skip to content

Instantly share code, notes, and snippets.

View hakusaro's full-sized avatar

Lucas Nicodemus hakusaro

View GitHub Profile
def add_warning_minecraft(target_name, message, admin_note, admin_id)
pin = Random.rand(9).to_s + Random.rand(9).to_s + Random.rand(9).to_s + Random.rand(9).to_s
while has_warning?(pin) do
pin = Random.rand(9).to_s + Random.rand(9).to_s + Random.rand(9).to_s + Random.rand(9).to_s
end
@sql_client.query("INSERT INTO warnings (id, target, aid, message, adminnote, sendtime, acktime, ack, pin, type)
VALUES (null, '#{@sql_client.escape(target_name)}', '#{admin_id}', '#{@sql_client.escape(message)}', '#{@sql_client.escape(admin_note)}',
'#{Time.now.to_i}', 0, 0, '#{pin}', 'mc')")
public int generateValidPinCode(String seed) {
int pin = 0;
Random r = new Random(System.nanoTime() + seed.hashCode());
int randombit = r.nextInt(9) * 1000 + r.nextInt(999);
ResultSet results = sqlDatabase.executeQuery("SELECT * FROM warnings WHERE pin=?", randombit);
try {
if (results.next()) {
pin = generateValidPinCode(Integer.toString(randombit));
} else {
@hakusaro
hakusaro / app.js
Created July 12, 2013 22:57
Rust kill tracker thing
var express = require('express');
var app = express();
var http = require('http');
var redis = require('redis');
var async = require('async');
var redis_client = redis.createClient(6379, "localhost");
//var redis_client = redis.createClient(port, host, options)
var eventId = 0;
app.listen(3000);
@hakusaro
hakusaro / buildmode.cpp
Created May 19, 2013 02:12
Not actually C++, it's SourcePawn.
//http://code.google.com/p/ihackedgmod/
//http://creativecommons.org/licenses/by-sa/3.0/
#include <sourcemod>
#include <sdktools>
#include <colors>
public Plugin:myinfo =
{
name = "Build Mode",
author = "nicatronTg",
@hakusaro
hakusaro / .bash_profile
Last active June 16, 2023 17:43 — forked from MichalPekala/.bash_profile
My Raspberry Pi's .bash_profile. Differences from original are purely aesthetic - no need for weather, and I like things to be lined up nicely when I ssh into my RPi.
#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
@hakusaro
hakusaro / gist:4489265
Created January 9, 2013 00:04
ItemMeta usage in Bukkit
ItemStack i = new ItemStack(Material.WRITTEN_BOOK);
ItemFactory itemFactory = plugin.getServer().getItemFactory();
BookMeta bookMeta = (BookMeta) itemFactory.getItemMeta(Material.WRITTEN_BOOK);
i.setItemMeta(bookMeta);
@hakusaro
hakusaro / shared.lua
Created May 2, 2012 06:59
Lua cluster grenade (Tribes: Ascend style)
if SERVER then
AddCSLuaFile ("shared.lua")
SWEP.Weight = 5
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = true
elseif CLIENT then
SWEP.PrintName = "Cluster Grenade"
SWEP.Slot = 5
SWEP.SlotPos = 1
SWEP.DrawAmmo = false