Skip to content

Instantly share code, notes, and snippets.

View Philipinho's full-sized avatar
🎯
Focusing on Java

Philip Okugbe Philipinho

🎯
Focusing on Java
View GitHub Profile
Don't worry about what anybody else is going to do. The best way to
predict the future is to invent it.
-- Alan Kay
Premature optimization is the root of all evil (or at least most of it)
in programming.
-- Donald Knuth
Lisp has jokingly been called "the most intelligent way to misuse a
computer". I think that description is a great compliment because it
@pklaus
pklaus / wikibackup.sh
Created December 11, 2010 19:06
wikibackup – A Basic Backup Script for MediaWiki
#!/bin/sh
####################################################################
# #
# Basic Backup Script for MediaWiki. #
# Created by Daniel Kinzler, brightbyte.de, 2008 #
# #
# This script may be freely used, copied, modified and distributed #
# under the sole condition that credits to the original author #
# remain intact. #
@MarioRicalde
MarioRicalde / youtube-url-regexp.php
Last active February 18, 2021 06:32
YouTube URL PHP Regexp Shit
<?php
/**
* YouTube Preg Match Test Case.
*
* @author Mario "Kuroir" Ricalde
*/
// Regular Expression (the magic).
$youtube_regexp = "/^http:\/\/(?:www\.)?(?:youtube.com|youtu.be)\/(?:watch\?(?=.*v=([\w\-]+))(?:\S+)?|([\w\-]+))$/";
@yeradis
yeradis / gist:1300642
Created October 20, 2011 08:02
show progress bar for loading data on Button click in android #android
#android
This is what you need:
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final ProgressDialog progress = ProgressDialog.show(THENAMEOFYOURACTIVITYCLASS.this,
ProgressTitle, ProgressMessage, true, false);
new Thread(new Runnable() {
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@fgelinas
fgelinas / _lang_util.php
Created April 16, 2012 01:03
Multilanguage site utility script
<?
/* _lang_util.php - Multilanguage site utility script
* This is my basic script to detect language and keep it in a cookie
*
* Language priority, from lowest to highest :
* - default lang
* - browser accepted lang
* - cookie lang
* - query parameter lang
*
@jboner
jboner / latency.txt
Last active November 18, 2024 08:23
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@cpjolicoeur
cpjolicoeur / gist:3590737
Created September 1, 2012 23:15
Ordering a query result set by an arbitrary list in PostgreSQL

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@deizel
deizel / tail.php
Created October 6, 2012 22:08
PHP log tail example
<?php
if (isset($_GET['ajax'])) {
session_start();
$handle = fopen('/private/var/log/system.log', 'r');
if (isset($_SESSION['offset'])) {
$data = stream_get_contents($handle, -1, $_SESSION['offset']);
echo nl2br($data);
} else {
fseek($handle, 0, SEEK_END);
$_SESSION['offset'] = ftell($handle);