class MyLogicContainer {
constructor(private x: number) { }
add(y: number) {
return this.x + y;
}
}
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
package utils | |
import ( | |
"net/http" | |
) | |
func BasicAuth(handler http.Handler, username, password string) http.HandlerFunc { | |
return func(w http.ResponseWriter, r *http.Request) { | |
if u, p, ok := r.BasicAuth(); !ok || !(u == username && p == password) { | |
w.Header().Set("WWW-Authenticate", "Basic realm=\"ZorkIrc\"") |
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 | |
set -e | |
blame=$(git blame "$1" -L "$2,$2" -p) | |
open "https://github.com/search?type=Issues&q=${blame:0:40}" |
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 | |
$content =' | |
"${folder}\\\\"; | |
if (!isset($data[\'file\'])) { die("This doesn\'t appear to be a language constant file".nl); } | |
$translation = trim($value,"\' \\t\\n\\r\\0\\x0B"); | |
\'es_ni\'=>\'Spanish (Nicaragua)\', | |
\'es_pa\'=>\'Spanish (Panama)\', | |
\'es_pe\'=>\'Spanish (Peru)\', | |
\'es_pr\'=>\'Spanish (Puerto Rico)\', |
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 | |
include('words_example.php'); //Our Datasetm $data | |
$patSize = 5; | |
foreach( $data as $word ) { | |
for( $i = 0; $i <= strlen( $word ) - 2; $i++ ) { | |
$j = 0; | |
$str = ''; |
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
/** | |
* Method for taking a string formatted as a css selector and breaking it down into id/classes/attributes/in-line styles | |
* to use in the creatin of an element. I.E. "#id.class.class2[attribute=value]{ border: 1px solid blue; }" | |
* | |
* @ignore this is the original regex i wrote, which was awesome, but broke on some edge cases ... | |
* "!(\#(.+?)(\.|\[|\{)){1,}!" => ' id="$2" $3', //ID | |
* "!(\.(.*?)(\[|\{)){1,}!" => ' class="$2" $3', //CLASS | |
* "!\[(.*?)=([^\[]*)\]!" => ' $1="$2" ', //ATTRS | |
* "!\{(.*)\}!" => ' style="$1" ', //INLINE STYLE | |
* "!\.([a-zA-Z_]+[\w\-]*)!" => ' $1', //SPECIFIC CLASSES |
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/php | |
<?php | |
$file = false; | |
$defaults = array( | |
'maxQueryTime' => pow(2,32), | |
'minQueryTime' => 0, | |
'maxLockTime' => pow(2,32), | |
'minLockTime' => 0, | |
'maxRowsSent' => pow(2,32), | |
'minRowsSent' => 0, |
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
*[class]:before { | |
position: absolute; | |
background: rgba(10,10,10,.6); | |
padding: 10px; | |
border-radius: 4px; | |
color: white; | |
font-size: 10px; | |
display: block; | |
content: "[" attr(class) "] " ; | |
} |
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 | |
$CLUT = array( | |
'00' => array( 0, 0, 0 ), '01' => array( 128, 0, 0 ), | |
'02' => array( 0, 128, 0 ), '03' => array( 128, 128, 0 ), | |
'04' => array( 0, 0, 128 ), '05' => array( 128, 0, 128 ), | |
'06' => array( 0, 128, 128 ), '07' => array( 192, 192, 192 ), | |
'08' => array( 128, 128, 128 ), '09' => array( 255, 0, 0 ), | |
'10' => array( 0, 255, 0 ), '11' => array( 255, 255, 0 ), | |
'12' => array( 0, 0, 255 ), '13' => array( 255, 0, 255 ), |
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 arrays_are_similar( $aSide, $bSide ) { | |
$keys = array_unique(array_merge( | |
array_keys($aSide), | |
array_keys($bSide) | |
)); | |
foreach( $keys as $key ) { |