Skip to content

Instantly share code, notes, and snippets.

```dataviewjs
// find dates based on format [[YYYY-MM-DD]]
const findDated = (task)=>{
if( !task.completed ) {
task.link = " " + "[[" + task.path + "|*]]";
task.date="";
const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/);
if(found) task.date = moment(found[1]);
return true;
}
@aunyks
aunyks / erc721-example.sol
Last active April 12, 2024 00:56
My implementation of the ERC721 token standard. WARNING: THIS CODE IS FOR EDUCATIONAL PURPOSES. DO NOT DEPLOY TO THE NETWORK.
pragma solidity ^0.4.19;
contract ERC721 {
string constant private tokenName = "My ERC721 Token";
string constant private tokenSymbol = "MET";
uint256 constant private totalTokens = 1000000;
mapping(address => uint) private balances;
mapping(uint256 => address) private tokenOwners;
mapping(uint256 => bool) private tokenExists;
mapping(address => mapping (address => uint256)) private allowed;
mapping(address => mapping(uint256 => uint256)) private ownerTokens;
...........
calculateVolumePriceConversionCoefficient = function(currentObj1, currentObj2, timestampForCalculation){
var timePassedObj1 = timestampForCalculation - currentObj1.LASTUPDATE;
var timePassedObj2 = timestampForCalculation - currentObj2.LASTUPDATE;
//negative or 0 cap it at 1
if(timePassedObj1 <=0 ){ timePassedObj1 = 1; }
if(timePassedObj2 <=0 ){ timePassedObj2 = 1; }
//if last update is more than 1 day ago cap it at 1 day
if(timePassedObj1 > 86400){ timePassedObj1 = 86400; }
@zmts
zmts / tokens.md
Last active July 22, 2024 18:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@MicahFulton
MicahFulton / gist:cbf4dc4ef1d0ccfd88d3
Created January 22, 2015 14:45
React JSX Autocompletions
{
"scope":"source.js",
"completions":[
{
"trigger":"a",
"contents":"<a${1}>${0}</a>"
},
{
"trigger":"abbr",
"contents":"<abbr${1}>${0}</abbr>"
@jareware
jareware / s3-curl-backups.md
Last active May 11, 2024 23:39
Simple, semi-anonymous backups with S3 and curl

⇐ back to the gist-blog at jrw.fi

Simple, semi-anonymous backups with S3 and curl

Backing stuff up is a bit of a hassle, to set up and to maintain. While full-blown backup suites such as duplicity or CrashPlan will do all kinds of clever things for you (and I'd recommend either for more complex setups), sometimes you just want to put that daily database dump somewhere off-site and be done with it. This is what I've done, with an Amazon S3 bucket and curl. Hold onto your hats, there's some Bucket Policy acrobatics ahead.

There's also a tl;dr at the very end if you just want the delicious copy-pasta.

Bucket setup

@nickytoh
nickytoh / iCloud API Demo in Node.js
Last active September 6, 2021 03:11
Request Contact List From iCloud
var uuid = require('node-uuid'),
https = require('https');
function iCloud(appleId, password) {
this.urls = {
"version" : "https://www.icloud.com/system/version.json",
"validate": "/setup/ws/1/validate?clientBuildNumber={0}&clientId={1}",
"login": "/setup/ws/1/login?clientBuildNumber={0}&clientId={1}"
}
@pixelhandler
pixelhandler / playing-with-orbit-js-and-ember-js.md
Last active February 22, 2018 21:55
Notes from Ember-SC April 2014 meetup - Playing with Orbit.js and Ember.js

Playing with Orbit.js and Ember.js

This presenation is an exploration of rolling your own data persistence for and Ember.js Application

During this discovery I attempt to roll my own data solution. I've selected to use alpha software, Orbit.js. So not also choosing other alpha software at the some time. Not covering es6, broccoli, ember-cli etc.

The exploratory app is based on converting my blog app (uses REST) to use Web sockets with a Node.js backend. I am using some build tools brunch.io also borrowing from tapas-with-ember. The modules in the source code are [CommonJS modules].

@Shilo
Shilo / ArchiveAndPackageApp.sh
Last active August 5, 2020 19:31
Bash shell script to clean, archive, and package xcode project. (Script extension can be renamed to .command to make it executable. Script must be located in the same directory as the .xcodeproj file)
#!/bin/bash
#configurable variables
SCHEME_NAME="SCHEME-NAME-HERE"
DEVELOPER_NAME="iPhone Distribution: YOUR_DEVELOPER_NAME_HERE (ID_HERE)"
PROVISIONING_PROFILE="/ABSOLUTE/PATH/TO/PROVISIONING/PROFILE_HERE.mobileprovision"
USE_DEFAULT_DEVELOPER_NAME=true
USE_DEFAULT_PROVISIONING_PROFILE=true
OPEN_DIR_WHEN_FINISHED=false
@jedi4ever
jedi4ever / nodejs-cluster-zero-downtime.md
Last active June 29, 2024 16:00
nodejs clustering, zero downtime deployment solutions

Clustering: The basics

The trick? pass the file descriptor from a parent process and have the server.listen reuse that descriptor. So multiprocess in their own memory space (but with ENV shared usually)

It does not balance, it leaves it to the kernel.

In the last nodejs > 0.8 there is a cluster module (functional although marked experimental)