CouchDB is a NoSQL database for storing JSON documents. It comes with a REST API out of the box so your client applications can persist data while requiring you to write little or no server-side code. CouchDB's killer feature is its ability to easily replicate, which allows for horizontal scaling, easy backup, and for client adapters to synchronize documents. This is perfect if you want to write an application that is offline-first. It's become my go-to database when creating new
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
// URL set in Synology would look something like this: | |
// https://<YOUR_SUB_DOMAIN>.azurewebsites.net/api/HttpTriggerJS1?hostname=__HOSTNAME__&ip=__MYIP__&zoneid=__USERNAME__&key=__PASSWORD__&email=<YOUR_CF_EMAIL_LOGIN>&dnsidentifier=<YOUR_DNS_ID_FROM_CF>&recordtype=A | |
module.exports = function (context, req) { | |
context.log('JavaScript HTTP trigger function processed a request.'); | |
var http = require('https'); | |
var hostname = req.query.hostname; | |
var ip = req.query.ip; | |
var zoneid = req.query.zoneid; |
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
// None of the tutorals could help me, so I adapted a few codes. | |
// What I really want is make a full duplex way between NodeJS and Java, using encrypt/decrypt with AES 128 bit | |
// 1 - you must have to generate the key | |
openssl enc -aes-128-cbc -k secret -P -md sha1 | |
// key examples: | |
// DCDD74627CD60252E35DFBA91A4556AA | |
// 2CB24CFDB3F2520A5809EB4851168162 | |
// 468CA14CA44C82B8264F61D42E0E9FA1 |
'use strict';
const crypto = require('crypto');
// get password's md5 hash
let password = 'test';
let password_hash = crypto.createHash('md5').update(password, 'utf-8').digest('hex').toUpperCase();
console.log('key=', password_hash); // 098F6BCD4621D373CADE4E832627B4F6
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 { createCipheriv, createDecipheriv, randomBytes } from "crypto"; | |
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters) | |
const IV_LENGTH: number = 16; // For AES, this is always 16 | |
/** | |
* Will generate valid encryption keys for use | |
* Not used in the code below, but generate one and store it in ENV for your own purposes | |
*/ | |
export function keyGen() { |
So you're writting a twitterbot and you need to authorize your application to post to the account. You need an access token and secret for the account you're posting to. If the posting account is the same account that owns the application, no problem, you just push the button on your application's settings page to make the keys. But if you want to post to a different twitter account, there's no UI on apps.twitter.com to authorize it. So I made this bare-minimum node server to run through the authorization process. There's probably a much better way to do this, so please let me know what that way is!
- You'll need a server with node.js!
- Make sure your application has a callback URL specified in its settings page, even if it's just a placeholder. If there's nothing in the callback URL slot, this method of authorization won't work.
- In authorize.js, fill in your application's consumer key and secret, and the domain on which you'll be running th
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 strict"; | |
var crypto = require("crypto"); | |
var EncryptionHelper = (function () { | |
function getKeyAndIV(key, callback) { | |
crypto.pseudoRandomBytes(16, function (err, ivBuffer) { | |
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ; |
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
//Bootstrap 3 grid inception | |
@mixin new-grid($class, $columns, $grid-gutter-width: $grid-gutter-width){ | |
$i: 1; | |
$grid-columns: $columns; | |
@include make-grid-columns($i: 1, $list: ".col-#{$class}-xs-#{$i}, .col-#{$class}-sm-#{$i}, .col-#{$class}-md-#{$i}, .col-#{$class}-lg-#{$i}"); | |
@include make-grid(#{$class}-xs); | |
@media (min-width: $screen-sm-min) { | |
@include make-grid(#{$class}-sm); | |
} |
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
jQuery.event.special.tap = { | |
add: function(handleObj){ | |
var $this = $(this); | |
var touchMoved = false; | |
var touched = false; | |
var touchesHandler = function(e){ | |
if(e.type === 'touchstart'){ | |
touchMoved = false; | |
touched = true; | |
}else if(e.type === 'touchmove'){ |
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
###* | |
* Encryption: | |
* | |
* cipher: AES-128-CBC | |
* key: 16 bytes | |
* IV: 16 bytes, random, non-reused, prepended to cipher text | |
* padding: PKCS#7 | |
### | |
crypto = require 'crypto' |
NewerOlder