Skip to content

Instantly share code, notes, and snippets.

View infynyxx's full-sized avatar
🫐

Prajwal Tuladhar infynyxx

🫐
View GitHub Profile
@infynyxx
infynyxx / replication.php
Created March 1, 2010 20:46 — forked from kchodorow/gist:318781
Get MongoDB replication info
<?php
function getReplicationInfo($m) {
$db = $m->local;
$result = array();
$ol = $db->system->namespaces->findOne(array("name" => 'local.oplog.$main'));
if ($ol && array_key_exists('options', $ol)) {
$result['logSizeMB'] = $ol['options']['size'] / 1000 / 1000;
#!/bin/bash
#
# MongoDB Backup Script
# VER. 0.1
# Note, this is a lobotomized port of AutoMySQLBackup
# (http://sourceforge.net/projects/automysqlbackup/) for use with
# MongoDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
a = function () {
for (var i = 0; i < 5; i++) {
print(i);
}
}
//expected: print 0 to 4
//value: prints entire function instead of executing it
@infynyxx
infynyxx / daemonize.c
Created June 11, 2010 09:19
code to create daemon in Linux
#include <unistd.h>
#include <sys/types.h>
#include <syslog.h>
#include <stdlib.h>
int daemonize();
void closelog();
int main(int argc, char **argv) {
daemonize();
@infynyxx
infynyxx / mysql_dump.sh
Created June 11, 2010 16:46
automated mysql dump using Linux Cron tab
#!/bin/sh
mysqldump -u root -pmysql123 –all-databases –routines| gzip > /root/MySQLDB_`date ‘+%m-%d-%Y’`.sql.gz
mysqldump -h 172.16.21.3 -u root -pmysql123 –all-databases –routines | gzip > /root/MySQLDB.3_`date ‘+%m-%d-%Y’`.sql.gz
#now create cron script smth like this
#crontab -e
#30 15 * * * /root/MySQLdump.sh 2>&1>> /root/MySQLdump.log
#The above will dump the database every day at 15:30.
@infynyxx
infynyxx / cgi_process
Created June 27, 2010 14:53
init.d Script for PHP FastCGI
#/etc/default/php-fastcgi
START=yes
# Which user runs PHP? (default: www-data)
EXEC_AS_USER=www-data
# Host and TCP port for FASTCGI-Listener (default: localhost:9000)
FCGI_HOST=localhost
FCGI_PORT=9000
@infynyxx
infynyxx / module_load_correct.js
Created July 3, 2010 04:45
Node.js Module Loading Incompatibility
/*This will work when loaded as module*/
exports.area = function(radius) {
return PI * radius * radius;
};
exports.circumference = function(radius) {
return PI * 2 * radius;
}
@infynyxx
infynyxx / browsers.conf
Created July 12, 2010 16:11 — forked from michaelklishin/browsers.conf
How to limit browser support to only recent versions of Chrome, Firefox, Internet Explorer and Safari in Nginx
#
# Supported browsers
#
modern_browser gecko 1.9;
# note that Safari related directives match
# Chrome, Mobile Safari, Palm Pre and other WebKit-based browsers here, too, thanks
# to all of them using almost identical User-Agent strings
modern_browser safari 3.0;
@infynyxx
infynyxx / html5_slides.html
Created July 13, 2010 17:28
Presentation Slides in HTML 5
<!DOCTYPE html>
<!--
Copyright 2010 Google Inc.
All rights reserved.
Original slides:
Marcin Wichary
Modifications:
Ernest Delgado
Alex Russell
@infynyxx
infynyxx / mongo_args
Created August 16, 2010 18:30
init.d script for MongoDB
MONGO_OPTS="--quiet --pairwith 192.168.1.6 --arbiter 192.168.1.5"