Skip to content

Instantly share code, notes, and snippets.

@fitsum
fitsum / semantic-version-validator-regex.js
Last active April 26, 2024 05:08
validates semantic versioning
//https://stackoverflow.com/questions/82064/a-regex-for-version-number-parsing
^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$
eg.
let ver = "0.0.1",
ptn = /^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/;
path.exec(version);
@fitsum
fitsum / fitsum.partition()
Last active April 26, 2024 05:08
lo dash's _partition() in longform
partition = function(inputArray, filterFunction){
/*
learn to make
Array.apply(null, {length: N}).map(Number.call, Number)
start from not zero
*/
var set = inputArray,
mods = set.map(filterFunction),
uniq = [],
arrays = {},
@zhuziyi1989
zhuziyi1989 / URL Schemes.md
Last active April 26, 2024 05:07
常用 URL Schemes 收集。

** 由于此文年事已久,可能某些URL Schemes已失效,可在评论区留言指出!(最后更新于 2024.4.16)

关于 URL Scheme 你知道多少?

iOS系统中

由于苹果的各应用都是在沙盒中,不能够互相之间访问或共享数据。但是苹果还是给出了一个可以在APP之间跳转的方法:URL Scheme。简单的说,URL Scheme就是一个可以让 APP 相互之间可以跳转的协议。每个 APP 的URL Scheme都是不一样的,如果存在一样的URL Scheme,那么系统就会响应先安装那个 APP 的URL Scheme,因为后安装的 APP 的URL Scheme被覆盖掉了,是不能被调用的。

Android系统中

@fitsum
fitsum / All-the-elements-and-all-the-styles.js
Last active April 26, 2024 05:07
all of them + just colors
console.clear();
Array.from(document.querySelectorAll('body, body *')).forEach((el) => {
var computedStyles = ['color', 'background-color'],
o = {
'c': "",
'bgc': ""
},
opts = {
'color': 'c',
@SpenceDiNicolantonio
SpenceDiNicolantonio / .prettierrc
Created April 26, 2024 04:46
Prettier config
{
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": true
}
@fitsum
fitsum / noaa.js
Last active April 26, 2024 05:06
noaa.js
console.clear()
var latLon = '38.9031,-77.0507',
getForecastURL = 'https://api.weather.gov/points/' + latLon;
forecast = async (url) => {
//let r = await fetch(url);
let j = await (await fetch(url)).json();
j.properties.forecast ? forecast(j.properties.forecast) : console.table(j.properties.periods)
}
o = {name: "Fitsum"}
f = function(obj){self = obj ? obj : this; return self.name}
f(o) === f.call(o)
//
@lokeshjawane
lokeshjawane / S3-to-GCS.js
Created September 25, 2018 12:43
Script to sync s3 obj to GCS in realtime
//This script is to copy S3 object to GCS in asynchronously using Lambda function
//set var "gcp_proj_id" with value of you GCP project ID
//set var "gcp_client_email" with value of your client email address from JSON key file & make sure that user has GCS create object permission
//set var "cred_bucket", here provode a s3 bucket from where lambsa will fetch the JSON creds file to GCP auth
//Set vat "cred_s3_obj", here you provide a json keyfile name which is uploaded in "cred_bucket" s23 bucket
//**NOTE**: set HOME env var with value "/tmp" in lambda function, because google-cloud/storage create file locally & in lambda only /tmp is writable. Run lambda function on S3 create object event based.
//
'use strict';
@YumaInaura
YumaInaura / ZSH.md
Last active April 26, 2024 05:04
Zsh — Mac OS option key for bindkey

Zsh — Mac OS option key for bindkey

Probably this is resolving of just binding as character.

Not related with like some escape sequences or special characters.

Example

In Mac OS bind Option + a

@fitsum
fitsum / if(array.indexOf(someObj) === -1) {add} else {next}
Last active April 26, 2024 05:02
check if obj exists in array then add if not
var source = [{name: "Fitsum", race: "blk"},{name: "Alice", race: "wht"},{name: "Jen", race: "wht"},{name: "Kim", race: "blk"},{name: "Lee", race: "asn"}],
target = [];
function userExists(name, idx, oldArr) {
return target.some(function(el) {
return el.name === name;
});
}
function addUser(name, idx, newArr) {