Skip to content

Instantly share code, notes, and snippets.

View agamm's full-sized avatar
🍪
Cookie: cookies=∞;\r\n

Agam More agamm

🍪
Cookie: cookies=∞;\r\n
View GitHub Profile
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@agamm
agamm / gist:5487668
Created April 30, 2013 09:36
Laravel 3 Naming Convenstions
1) Database:
table name (Eg. users)
field name (Eg. department_id)
2)Controllers:
Name_of_the_controller + _Controller. (Where the name of the controller normally starts with a capital letter. The filename should be the same with name of the controller.)
3) Models:
Name_Model (try to spesify in a single word (eg. no underscores).
@agamm
agamm / autoscroll
Created July 5, 2013 21:08
Automatically scroll webpages (nice for reading online) Installation: Create a new bookmark, call it: "Autoscroll", and in the URL field enter the code below:
javascript: var x = 1 * prompt("Start From:", window.pageYOffset);var s = 1 * prompt("Speed:", 0.03);var time = document.createElement("div");time.style.position = "fixed";time.style.top = "90%";time.style.left = "90%";document.body.appendChild(time);if (x != null && s !== null) {window.setInterval(function () {if (x + window.innerHeight <= document.height) {x += s;document.body.scrollTop = x;time.innerHTML = ((document.height - (x + window.innerHeight)) / (s * 100)).toFixed(2) + "s";}}, 10);}
@agamm
agamm / gist:6065556
Created July 23, 2013 19:49
My Basic Grunt Setup
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */'
},
my_target: {
@agamm
agamm / gist:6271077
Created August 19, 2013 16:30
Epic up shell command. Tired of doing cd .. or cd ../ all the time?
up(){
limit=$1
startloc=`pwd`
for((i=1 ; i <= limit ; i++))
do
cd ..
done
echo "From: $startloc"
echo 'To: ' `pwd`
}
@agamm
agamm / gist:d9bf9a1818e7142db311
Created March 13, 2015 21:03
XOR neural network
import pybrain
from pybrain.datasets import *
from pybrain.tools.shortcuts import buildNetwork
from pybrain.supervised.trainers import BackpropTrainer
import pickle
if __name__ == "__main__":
ds = SupervisedDataSet(2, 1)
ds.addSample( (0,0) , (0,))
ds.addSample( (0,1) , (1,))
@agamm
agamm / gist:7a839180075b77220729
Last active October 13, 2022 22:26
Simple time logging class in PHP.
<?php
//Exec time class
/*
Example:
Time::start('functionToTest');
functionToTest();
Time::p();
Time::t();
*/
class Time{
@agamm
agamm / random.js
Last active October 13, 2022 22:07
Javascript random choice picker.
function makemychoice() {
args = Array.prototype.slice.call(arguments);
return ( args[~~(args.length * Math.random())] ) + " was chosen.";
}
// Example: makemychoice("Go to run", "Go to swim", "Fix bug");
// from the creator of unzip.dev
@agamm
agamm / gist:e0363f4998e39703daa0
Created May 16, 2015 20:45
Custom Go HTTP Response
func all(w http.ResponseWriter, r *http.Request) {
someText := "Some custom message for the redirect"
hj, ok := w.(http.Hijacker)
if !ok {
http.Error(w, "Webserver doesn't support hijacking", http.StatusInternalServerError)
return
}
conn, bufrw, err := hj.Hijack()
checkErr(w, err)
@agamm
agamm / run.bat
Last active October 13, 2022 22:06
Start react-native on Windows
set /p id="(Reminder) Did you start a vm? and is it available in adb? "
start cmd /k react-native start
rem *** HACK ALERT: Sleep for 10 seconds ***
ping -n 10 127.0.0.1 > nul
start cmd /k react-native run-android
REM Might you want to visit unzip.dev ?