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
/* | |
I was able to achieve these speeds on my laptop: Intel Core i7-4500U @ 1.80GHZ | |
2015/08/19 18:48:26 Test 1: 664579 took 51.0003ms | |
2015/08/19 18:48:27 Test 2: 5761455 took 693.0054ms | |
2015/08/19 18:48:35 Test 3: 50847534 took 8.229995s | |
*/ | |
package main | |
import ( |
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 main | |
import "fmt" | |
type Expr interface { | |
Simplify() Expr | |
simplify() Expr | |
} | |
type const_ struct{ val int } |
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 main | |
import "fmt" | |
type Expr interface{} | |
type const_ struct{ val int } | |
type var_ struct{ name string } | |
type add struct{ left, right Expr } | |
type mult struct{ left, right Expr } |
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
struct block{ | |
uint8_t v[BYTES_IN_BLOCK]; | |
block(){ memset(v, 0, BYTES_IN_BLOCK); } | |
uint64_t& operator[](uint8_t i){ return *(uint64_t*)(v + 8 * i); } | |
block& operator=(const block& r){ memcpy(v, r.v, BYTES_IN_BLOCK); return *this; } | |
block& operator^(const block& r){ block a; for (unsigned j = 0; j < BYTES_IN_BLOCK; ++j) a.v[j] = v[j] ^ r.v[j]; return *this; } | |
}; |
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
CREATE OR REPLACE FUNCTION process_password_audit() RETURNS TRIGGER AS $password_audit$ | |
BEGIN | |
IF NEW.password <> OLD.password THEN | |
SELECT pg_notify('passwordchange', NEW); | |
ENDIF; | |
RETURN NULL; | |
END; | |
$password_audit$ LANGUAGE plpgsql; | |
CREATE TRIGGER password_audit AFTER UPDATE ON users |
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
/** | |
* Sets the ID of the first element with the class name NAME | |
* to the UID that corresponds with the window's width. | |
* | |
* @param {string} name A string providing the class name of the ad element | |
* needing its ID changed. | |
* @throws {Error} If document.getElementsByClassName(name) can't find the | |
* element. | |
* @return {string} The uid. | |
*/ |
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
type CoolMap map[string]interface{} | |
func (c *CoolMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error { | |
var err error | |
for key, val := range *c { | |
st := xml.StartElement{ | |
Name: xml.Name{Local: key}, | |
} | |
err = e.EncodeElement(val, st) |
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 bash | |
set -euo pipefail | |
// setting up stuff. | |
if [ "$RUN" = true ]; then | |
RUNSCRIPT="${BIN} ${ARGS} ${GLOGARGS} ${PROFARGS}" | |
echo -e "Running ${RUNSCRIPT}\n" | |
echo "----------------------------" | |
source envvar.bash # <- variable declarations are in here, and I can echo them. |
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
eric@archbox ~/gopath/src/github.com/company/prog/testing $ cat build.bash | |
#!/usr/bin/env bash | |
set -euo pipefail | |
# export TEST_ENV="hello, world!" | |
source ev.bash | |
go build envtest.go && ./envtest | |
eric@archbox ~/gopath/src/github.com/company/prog/testing $ cat ev.bash |
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 bash | |
set -euo pipefail | |
export TEST_VAR="Hello, world!" |