Skip to content

Instantly share code, notes, and snippets.

View Vitexus's full-sized avatar
🤖
Coding as usual

Cybervitexus Vitexus

🤖
Coding as usual
View GitHub Profile
@RaVbaker
RaVbaker / readme.md
Created March 30, 2012 20:12
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@mgdelacroix
mgdelacroix / gist:2397424
Created April 16, 2012 10:04
Rename a file in Groovy
def file = new File("/tmp/image.jpg")
println ">> Nombre del fichero: ${file.name}"
println "HACEMOS EL RENAME"
def string = "/tmp/${file.name[0..-5]}_thumb.jpg"
def newFile = new File(string)
file.renameTo(newFile)
println ">> Nombre del fichero: ${newFile.name}"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@gingerlime
gingerlime / change_db_owner.sh
Created April 24, 2012 19:32
Postgresql - Changing ownership on all tables
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
@phred
phred / pedantically_commented_playbook.yml
Last active February 26, 2025 14:19
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@lebedov
lebedov / headless.sh
Created August 13, 2012 19:50
Using Xvfb to create a headless display
#!/bin/bash
# Demonstrates how to create a headless display using xvfb.
# Create the display:
Xvfb :100 -ac &
PID1=$!
export DISPLAY=:100.0
# Run the application that needs the display:
@superbrothers
superbrothers / ansi-color.php
Created August 23, 2012 01:49
ANSI color terminal output module for php
<?php
/**
* php-ansi-color
*
* Original
* https://github.com/loopj/commonjs-ansi-color
*
* @code
* <?php
* require_once "ansi-color.php";
@pkern
pkern / archive-mails
Created September 16, 2012 00:24 — forked from fwenzel/cleanup-maildir.py
A script for cleaning up mails in Maildir folders, with proper threading support
#!/bin/sh
BASE=$HOME/Maildir
ARCHIVEBASE=$HOME/Maildir/archive.
for folder in `find $BASE -maxdepth 1 -type d \! -regex '.*/archive\..*' \! -name cur \! -name tmp \! -name new`
do
folder=$(basename $folder)
if [ "${folder}" = "Maildir" ]; then folder=INBOX; fi
./cleanup-maildir.py --archive-folder=${ARCHIVEBASE}${folder} --maildir-root=$BASE --folder-prefix= --age=365 -d 1 -k -u -v archive ${folder}
@larsks
larsks / wait-for-network.ps1
Created November 4, 2012 12:56
Wait until networking is available with PowerShell
# Wait for a DHCP-enabled interface to develop
# a default gateway.
#
# usage: wait-for-network [ <tries> ]
function wait-for-network ($tries) {
while (1) {
# Get a list of DHCP-enabled interfaces that have a
# non-$null DefaultIPGateway property.
$x = gwmi -class Win32_NetworkAdapterConfiguration `
-filter DHCPEnabled=TRUE |
@jayjanssen
jayjanssen / gist:4039319
Created November 8, 2012 15:02
sysctl tuning for HAproxy
net.core.somaxconn = 32768
net.ipv4.conf.all.send_redirects = 1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 262144
net.ipv4.tcp_mem = 200000    280000    300000