This file contains hidden or 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
| -- We have a table (ip_log) of proper IPv4 addresses (ip) | |
| select bitand(ip / 16777216, 255) || '.' || bitand(ip / 65536, 255) || '.' || bitand(ip / 256, 255) || '.' || bitand(ip, 255) ip | |
| from ip_log; | |
| -- ...or a function to do the same: | |
| create or replace function long2ip(ip in number) | |
| return varchar2 deterministic | |
| as | |
| begin | |
| return bitand(ip / 16777216, 255) || '.' || |
This file contains hidden or 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
| // The easy way to get unique items from an array | |
| Array.prototype.unique = function() { | |
| return this.filter(function(s, i, a){ return i == a.lastIndexOf(s); }); | |
| }; | |
| // Translated into jQuery, so it works in IE8 :P | |
| Array.prototype.unique = function() { | |
| var array = this; | |
| return $.grep(array, function(v, i) { return $.inArray(v, array, i + 1) == -1; }); | |
| }; |
This file contains hidden or 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() { | |
| var isWord = function(word) { return /^[a-z]+$/i.test(word); }, | |
| exceptions = { | |
| man: 'men', | |
| woman: 'women', | |
| child: 'children', | |
| mouse: 'mice', | |
| tooth: 'teeth', | |
| goose: 'geese', |
This file contains hidden or 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
| String.prototype.toCamelCase = function() { | |
| return this.toLowerCase() | |
| .replace(/[^\w\s]/g, '') | |
| .replace(/\s+(\w)/g, function(match, $1) { return $1.toUpperCase(); }); | |
| }; |
This file contains hidden or 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
| #include <stdio.h> | |
| typedef struct { | |
| char* haystack; | |
| char* needle; | |
| int found; | |
| } unitTest; | |
| int strstr(char* haystack, char* needle) { | |
| int i = 0, |
This file contains hidden or 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
| Number.prototype.ordinal = function() { | |
| return this < 0 ? undefined | |
| : this + ['th', 'st', 'nd', 'rd'][this % 10 < 4 ? (this % 10) * (parseInt(this / 10, 10) % 10 == 1 ? 0 : 1) : 0]; | |
| } |
This file contains hidden or 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
| ' ADO Abstraction Class for VBA | |
| ' Christopher Harrison | |
| ' This is meant for simple, read-only access to an ODBC database (e.g., for | |
| ' report writing in Excel, etc.). It constructs parameterised queries, with | |
| ' optional varchar parameters (ordered, not named) passed as a collection. | |
| ' (SELECT statements, at least, are weakly typed (or can be casted), so using | |
| ' strings isn't really a concern.) | |
| ' Notes: |
This file contains hidden or 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
| import random | |
| import itertools | |
| import bisect | |
| BNC = [ | |
| ('the', 6187267), | |
| ('be', 4239632), | |
| ('of', 3093444), | |
| ('and', 2687863), | |
| ('a', 2186369), |
This file contains hidden or 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
| if (!window.query) { | |
| (function () { | |
| var match, | |
| search = /([^&=]+)=?([^&]*)/g, | |
| decode = function (s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }, | |
| query = window.location.search.substring(1); | |
| window.query = {}; | |
| while (match = search.exec(query)) { | |
| window.query[decode(match[1])] = decode(match[2]); |
This file contains hidden or 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 | |
| require_once "error.php"; | |
| class Oracle { | |
| private $connection; | |
| private $connected; | |
| function __construct($connectionString, $username, $password) { | |
| global $err; |