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
const binSearch = (list, val) => { | |
let min = 0, max = list.length - 1, index, guess; | |
while(min <= max) { | |
index = Math.ceil((min + max) / 2, 10); | |
guess = list[index]; | |
if (guess === val) { | |
return index; | |
} else if (guess > val) { | |
max = index - 1; |
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
// @flow | |
export class ApiCall { | |
constructor(url: string) { | |
this.url = url; | |
} | |
get = (id?: string) => app.api.get(id ? `${this.url}/${id}` : this.url); | |
post = (body: object = {}) => app.api.post(body); | |
put = (body: object = {}) => app.api.put(body); | |
delete = (id?: string) => app.api.delete(`${this.url}/${id}`); |
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 | |
/** | |
* UniqueFileName | |
* Check whether file exists in path, and build unique name for them | |
*/ | |
class UniqueFileName | |
{ | |
/** | |
* @var string path to directory where file suppose to be located |
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 | |
/** | |
* UploadErrorMessage | |
*/ | |
class UploadErrorMessage | |
{ | |
/** | |
* @var int upload error code | |
*/ |
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
import React from 'react'; | |
export default class extends React.PureComponent { | |
onSubmit = (event) => { | |
event.preventDefault(); | |
const { action, method, elements } = event.target; | |
const data = Array.from(elements).reduce( (result, currentElement) => ({ | |
[currentElement.id]: currentElement.value, | |
...result |
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
## | |
## Prefer mongodump/mongorestore instead of mongoexport/mongoimport, | |
## as it will "export" additional metadata, like indexes etc. | |
## | |
### Mongodump example | |
# Required: host, db, collection, out | |
# Optional: query (limit results) | |
mongodump --host mongodb1.example.net \ |
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 | |
/** | |
* Autoload: | |
* new A() -> A.php | |
* new B1\A1\A -> B1/A1/A.php | |
*/ | |
class Autoload | |
{ | |
protected $_basePath; |
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 | |
require_once 'application.php'; | |
require_once 'generator.php'; | |
$app = new Application($_GET, $_POST); | |
$testGenerator = Generator::factory(); | |
try { | |
$app->execute(); | |
} catch(Exception $e) { |
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 | |
# | |
# Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/ | |
# release 1 PHP5.4 to 5.3 by Emil Terziev ( foxy ) Bulgaria | |
# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474 | |
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories: | |
echo "Am I root? " | |
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then |