Skip to content

Instantly share code, notes, and snippets.

View dariusc93's full-sized avatar

Darius Clark dariusc93

View GitHub Profile
@dariusc93
dariusc93 / ipv4.rs
Created January 13, 2016 12:32
Basic IPv4 Management
use std::net::Ipv4Addr;
pub struct IPv4Network {
pub ip: Ipv4Addr,
pub prefix: u8
}
pub struct IPv4Iter {
pub state: Ipv4Addr,
#
#Generic Kickstart template for Ubuntu
#Platform: x86 and x86-64
#
# Customized for Server 14.04 minimal vm install
#
# Usage:
# - Look through config for any changes you want to do. You may want to change
# the initial admin user. Currently username is ubuntu and password is
# ChangeMe. Also may want to change the list of installed packages. Tried to
@dariusc93
dariusc93 / gist:8223559
Created January 2, 2014 18:11
Example of image resizing
module.exports = {
index: function(req,res){
var name = req.params.name;
var sub = name.split('.'),fname = sub[sub.length-2],ext = sub[sub.length-1];
var imgpath = __dirname+'/../../assets/img/'+fname+'.'+ext;
require('fs').exists(imgpath, function(exist){
if(exist){
var Canvas = require('canvas'),
Image = Canvas.Image,
module.exports = {
index:function(req,res){//get /test in routes.js
res.view('test');
},
upload:function(req,res){//post /upload in routes.js
console.log(req.files.uploadfile);
var path = '/home/projects/upload/'+req.files.uploadfile.name;
require('fs').rename(req.files.uploadfile.path,path,function(err){
if(err) throw err;
fs.chmodSync(path,440);//for *nix systems
app.get('/img/:width/:height/:name', function(req,res){
var name = req.params.name;
var sub = name.split('.'),fname = sub[sub.length-2],ext = sub[sub.length-1];
var d1 = ['/path/to/',fname,'.',ext];
fs.exists(d1.join(""), function(exist){
if(exist){
var img = new image;
console.log(d1.join(''));
img.onerror = function(err){
app.get('/img/:x/:y/:name', function(req,res){
var x = req.params.x,
y = req.params.y;
var sub = req.params.name.split('.'),
name = sub[sub.length-2],
ext = sub[sub.length-1];
var d1 = ['/path/to/',name,'.',ext];
fs.exists(d1.join(""), function(exist){
if(exist){
var image = Canvas.Image,
var connection = mysql.createConnection(dbconfig);
function doExist(data, callback){
connection.connect();
connection.query('select * from testaccount where username=?',[data.username], function(err,rows){
//if(err) throw err;
console.log(rows);
if(rows[0].username){
callback(true);
}else{
@dariusc93
dariusc93 / gist:7407706
Created November 11, 2013 04:10
Backup of database example
sync; mysqldump -uroot -pPasswordhere database > /path/to/backup/database-$(date "+%Y.%m.%d-%H").sql
@dariusc93
dariusc93 / gist:7268481
Created November 1, 2013 17:04
Before C++ plugin added
var irc = require('irc'),
http = require('http');//,
//ircsync = require('ircsync');
var bot = new irc.Client('irc.freenode.net', 'minelitecoin-bot', {channels: ['#mine-litecoin']});
bot.addListener('message', function(from, to, message){
if(message == '?help'){
bot.say('#mine-litecoin', 'If you need help with getting started visit http://mine-litecoin.com/index.php?page=getting%20started');
}