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 xml.etree.ElementTree as ET | |
import pandas as pd | |
def make_field(parent_el, attrib={}, text=None): | |
attrib = dict([e for e in attrib.items() if e[1] is not None]) | |
e = ET.SubElement(parent_el, 'field', attrib) | |
if not text is None: | |
e.text = text | |
return 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
const { authenticator } = require('otplib') | |
const crypto = require('crypto') | |
authenticator.options = { crypto } | |
const rawSecret = crypto.randomBytes(32).toString('hex').substr(0, 20) | |
const secret = authenticator.encode(rawSecret) | |
console.log('secret', secret) | |
console.log('url', authenticator.keyuri('[email protected]', 'testing-otplib', secret)) |
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, { useState, useEffect } from 'react' | |
import { useAsyncStorage } from '@react-native-community/async-storage' | |
export default function usePersistedState(initialValue, { key }) { | |
if (!key) { | |
throw new Error('key is required'); | |
} | |
const [localState, setLocalState] = useState(initialValue) | |
const { getItem, setItem } = useAsyncStorage('@' + key) |
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
// just foolin around | |
List<int> f() { | |
return List.generate(20, (i) => i * i); | |
} | |
void main() { | |
for (int i = 0; i < 5; i++) { | |
print('hello ${i + 1}, $i'); | |
} |
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
[ | |
{ | |
"page": 1, | |
"pages": 1, | |
"per_page": "50", | |
"total": 42 | |
}, | |
[ | |
{ | |
"id": "ABW", |
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
// inspired by https://github.com/moment/moment/issues/1048#issuecomment-23998922 | |
const m = require('moment') | |
const displayDuration = (start, end) => { | |
const diff = end.diff(start) | |
const hours = end.diff(start, 'hour') | |
return hours === 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
// a "generic" function doing some work for us (in this case, just multiply | |
// value with a factor `n`) | |
function times(value, n) { | |
return value * n; | |
} | |
// "higher order function" to generate more specific functions | |
function makeTimes(n) { | |
return function(value) { | |
return times(value, n); |
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
var express = require('express'); | |
var app = express(); | |
var port = 3100; | |
app.listen(port, function() { | |
console.log('listening on port ' + port); | |
}); | |
/* public routes */ |
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
- certain endpoints are always blocked | |
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then | |
ngx.exit(403) | |
end | |
-- import requirements | |
local cjson = require "cjson" | |
-- setup some app-level vars | |
local app_id = "APP_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
$ModLoad /usr/lib/rsyslog/ommail.so | |
$ActionMailSMTPServer localhost | |
$ActionMailFrom [email protected] | |
$template mailSubject,"Rsyslog alert for %hostname% at %timegenerated%" | |
$template mailBody,"%msg%" | |
$ActionMailSubject mailSubject | |
$ActionExecOnlyonceEveryInterval 60 | |
$ActionMailTo [email protected] | |
if ($msg contains 'demo') or ($msg contains 'test') then :ommail:;mailBody |
NewerOlder