Skip to content

@raphy202
raphy202 / switch_case.rb
Last active August 29, 2015 14:14
switch case in ruby
case a
when 1
puts "Single value"
when 2, 3
puts "One of comma-separated values"
when 4..6
puts "One of 4, 5, 6"
when 7...9
puts "One of 7, 8, but not 9"
when 1..4, 5
@ymychf
ymychf / RegularExpressionMatch
Created February 8, 2015 14:49
Regular Expression Matching
/**
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype should be:
//Getting Page name
var pagetitle = document.getElementsByTagName("title")[0].innerHTML.substr(11);
console.log('You are about to SCRAPE the ' + pagetitle);
//Function for getting UIDS
function getAllLink(){
var class1 = document.getElementsByClassName('fwb fcg');
var array1 = [];
for(i=0;i<class1.length;i++){
var str = class1[i].getElementsByTagName('a')[0].href;
var partres = str.split("?");
@Boot-Error
Boot-Error / Pyramid
Created February 8, 2015 17:39
This generates a pyramid of numbers.. using python.
# Maximum Limit
limit = 20
# generates the series as a list
pyramid = [a[0:-1]+a[::-1] for a in ["".join([str(k) for k in range(1, i+1)]) for i in range(1, limit+1)]]
# pretty print
for num in pyramid:
print num.center(len(pyramid[-1]))
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward
@andy-esch
andy-esch / index.html
Last active August 29, 2015 14:15
Use bounding box to calculate values to populate a chart
<!DOCTYPE html>
<html>
<head>
<title>Custom infowindow example | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body {
height: 100%;
@cdrnet
cdrnet / keybase.md
Created February 8, 2015 16:10
keybase.md

Keybase proof

I hereby claim:

  • I am cdrnet on github.
  • I am cdrnet (https://keybase.io/cdrnet) on keybase.
  • I have a public key whose fingerprint is 41C6 ACE0 ACD1 FD51 D565 2884 B33F 7C2A D58B 2816

To claim this, I am signing this object:

@qybl
qybl / if_errors.tmpl
Last active August 29, 2015 14:15
Graphing interface errors with MRTG
# Author: Tobias Oetiker <[email protected]>
# Date: 2006-09-06
# Purpose: Add an Error graph for each Traffic Graph
# 02/07/2015: add juniper interface errors / Hannes Rist
# i am soooo sorry for this
# see http://www.oidview.com/mibs/2636/JUNIPER-IF-MIB.html
my @special_oid_name = ('ifJnxInFrameErrors', 'ifJnxInQDrops','ifJnxInRunts');
my @special_oid = ('1.3.6.1.4.1.2636.3.3.1.1.10','1.3.6.1.4.1.2636.3.3.1.1.11','1.3.6.1.4.1.2636.3.3.1.1.12');
my @special_oid_desc = ('Framing Errors: The number of input packets which were misaligned.','Drops: The number of packets dropped by the input queue ofthe I/O Manager ASIC.','Runts: Frames received that are smaller than the runt threshold.');
public class Solution {
public List<String> wordBreak(String s, Set<String> dict) {
List<String> result = new ArrayList<String>();
if (s == null || dict == null) {
return result;
}
int len = s.length();
boolean[] dp = new boolean[len + 1];
dp[0] = true;
@joshenders
joshenders / libhttpd.c.patch
Created February 8, 2015 06:51
X-Forwarded-For patch for thttpd-2.26
--- libhttpd.c 2014-12-10 12:53:07.000000000 -0800
+++ libhttpd.c.patched 2015-02-07 22:44:59.183663432 -0800
@@ -2231,6 +2231,12 @@
if ( strcasecmp( cp, "keep-alive" ) == 0 )
hc->keep_alive = 1;
}
+ else if ( strncasecmp( buf, "X-Forwarded-For:", 16 ) == 0 )
+ { // Use real IP if available
+ cp = &buf[16];
+ cp += strspn( cp, " \t" );