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
from multiprocessing import Process, Queue | |
from pathlib import Path | |
from typing import Literal | |
import alembic.command | |
from alembic.config import Config | |
from fastapi import FastAPI | |
from pydantic import BaseModel |
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 | |
// If we hadn't gone with `redis` I would have implemented something like this | |
// for abstracing away the "complicated" stuff... | |
class NsCache() { | |
// ... | |
/** | |
* Get cache from namespace |
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
from schematics.models import Model | |
from schematics.types import BaseType, StringType, BooleanType, IntType | |
from schematics.types.compound import ListType, ModelType as _ModelType, DictType | |
from schematics.transforms import blacklist, export_loop | |
import ruamel.yaml as yaml | |
from ruamel.yaml.comments import CommentedMap | |
from ruamel.yaml.scalarstring import PreservedScalarString | |
from ruamel.yaml.compat import string_types, ordereddict |
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 {isArray, cloneDeep} from 'lodash' | |
export class ExtendableError extends Error { | |
constructor(message) { | |
super(message) | |
this.name = this.constructor.name | |
this.message = message | |
Error.captureStackTrace(this, this.constructor.name) | |
} |
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
class SimpleEventEmitter: | |
_events: [] | |
_onceWrapper: (type) -> | |
wrapper = ~> | |
@off(type, wrapper) | |
fn.apply(this, arguments) | |
on: (type, fn, once=false) !-> | |
@_events[type] = @_events[type]? or [] |
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 url = $("script[src$='findfilehosttest.js']").attr('src') | |
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i) | |
var domain = matches && matches[1] | |
alert(domain) | |
}) |
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 R($param, $default=null, $type='string') { | |
if(!isset($_REQUEST[$param])) | |
return $default; | |
$r = $_REQUEST[$param]; | |
if($type === 'bool' || $type === 'boolean') { | |
if($r === 'false' || $r === 'no') | |
return false; | |
return !empty($r); | |
} | |
settype($r, $type); |
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 nearestInList(number, list, returnDistance) { | |
var distance = Infinity; | |
var n = null; | |
for(var i in list) { | |
var _distance = Math.abs(list[i] - number); | |
if(_distance < distance) { | |
distance = _distance; | |
n = list[i]; | |
} |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 | |
$xml_url = 'http://www.arionbanki.is/markadir/gjaldmidlar/gengi/xml-export'; | |
$data = simplexml_load_file($xml_url); | |
$out = array( | |
'timestamp' => time(), | |
'base' => 'ISK', | |
'rates' => array() | |
); |
NewerOlder