This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### | |
# This config file enables 802.11/n speeds with RealTek | |
# 27x0 and 28x0 model pci wireless networking cards in | |
# Linux. Create the directory /etc/Wireless/RT2860STA/ | |
# and name this file RT2860STA.dat to use. | |
# | |
# Originally posted: | |
# http://ww.ubuntuforums.org/showpost.php?p=8346399&postcount=9 | |
# | |
# The word of "Default" must not be removed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isPrime($number) { | |
// A prime number is only divisible by 1 and itself. | |
// All numbers are divisible by 1, so start with 2. | |
for ($div = 2; $div < $number; $div++) { | |
// If $number is wholly divisible by $div (no remainder). | |
if (($number % $div) === 0) { | |
// If we can evenly divide $number by anything that | |
// is not 1 or itself, it is not prime and we can return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = "My product Vol. 002 Season 03"; | |
$new_string = preg_replace(/\b0+(?=\d+\b)/, '', $string); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from urllib import urlopen, quote | |
url = 'http://www.example.com/example.jpg' | |
# Check valid url | |
resource = urlopen(url) | |
status = resource.getcode() | |
content_type = resource.info().get('Content-Type') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bind input placeholder text | |
$(document).ready(function() { | |
// Check for placeholder support | |
var i = document.createElement('input'); | |
if (('placeholder' in i) == false) { | |
$('input[placeholder]').each(function() { | |
// Set initial value and class | |
if ($(this).val() == '' || $(this).val() == $(this).attr('placeholder')) { | |
$(this).val($(this).attr('placeholder')).addClass('placeholder-text'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2011 Tristan Waddington <[email protected]> | |
* | |
* Permission to use, copy, modify, and distribute this software for any | |
* purpose with or without fee is hereby granted, provided that the above | |
* copyright notice and this permission notice appear in all copies. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!#/bin/bash | |
## | |
# Install requirements for Apache2, MySQL, PHP, Django, Rails | |
# on Debian/Ubuntu. | |
## | |
sudo apt-get install \ | |
apache2 \ | |
apache2-doc \ | |
apache2-suexec \ | |
sqlite3 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function search(str1, str2) { | |
var i,n; | |
for (i=0; i<str2.length; i++) { | |
for (n=0; n<str1.length; n++) { | |
var c1 = str1.charAt(n); | |
var c2 = str2.charAt(i+n); | |
if (c1 === c2) { | |
if (n === (str1.length-1)) { | |
return i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search(needle, haystack, end=False): | |
""" | |
A naive string searching function. | |
""" | |
n = len(needle) | |
h = len(haystack) | |
start = 0 | |
offset = n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CSV { | |
protected $data; | |
/* | |
* @params array $columns | |
* @returns void | |
*/ | |
public function __construct($columns) { | |
$this->data = '"' . implode('","', $columns) . '"' . "\n"; |
OlderNewer