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 windows events | |
""" | |
import os | |
def create_event(srcname: str, type: str, id: int, description: str): | |
command = f'eventcreate /t {type} /id {id} /l application /so {srcname} /d "{description}"' | |
os.system(f'cmd /c "{command}"') | |
def post_info_event(srcname: str, id: int, description: 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
const _sessionStore = {}; | |
const sessionStore = { | |
getItem: (id) => _sessionStore[id] || null, | |
setItem: (id, value) => _sessionStore[id] = value, | |
clear: () => _sessionStore = {}, | |
} | |
/** | |
* |
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
/** | |
* Taken from a few web snippets | |
*/ | |
function tableToExcel(table, name = '', filename = "export.xls") { | |
const uri = 'data:application/vnd.ms-excel;base64,' | |
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>' | |
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } | |
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } | |
if (!table.nodeType) |
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
function round(n, e) { | |
const f = e === 0 ? 1 : Math.pow(10, e); | |
return Math.round(n * f) / f; | |
} | |
// test examples | |
/* | |
> round(123.123, 2) | |
< 123.12 |
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
let composeP = (...fns) => p => | |
fns | |
.reduceRight( | |
(acc, it) => | |
Array.isArray(it) | |
? acc.then(it[0], it[1]) // ).catch( | |
: acc.then(it), | |
p | |
); |
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
Promise.prototype.ap = function(p) { | |
const self = this; | |
return p.then(v => self.then(f => f(v))); | |
} | |
const add = | |
a => b => a + b; | |
console.log(add(1)(2)); // 3 |
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, { Component } from 'react'; | |
import { Text, View, StyleSheet, VirtualizedList, Dimensions, TouchableOpacity } from 'react-native'; | |
import { Constants } from 'expo'; | |
const arrItems = 'Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,1,2,3,4,5,6,7,8,9,0'.split(',').map(it => ({key: it})); | |
const Item = ({item, width, selectedItems, setItem}) => { | |
const isActive = selectedItems.indexOf(item.key) > -1; | |
return ( | |
<TouchableOpacity |
NewerOlder