{
client: 'pg',
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
class Blog(django.model): | |
name = models.CharField(null=False, max_length=64) | |
def list_articles(self): | |
return [ | |
{'body': 'abcdefg'}, | |
{'body': 'abcdefg'}, | |
{'body': 'abcdefg'}, | |
] |
# dataclass saves the trouble of writing __init__ implementations | |
# frozen=True makes the class instances immutable (so no hidden mutable state) | |
@dataclass(frozen=True) | |
class UserConnector: | |
def get_user(id: str) -> User: | |
return User.objects.get(id=id) | |
@dataclass(frozen=True) | |
class OrgConnector: | |
def get_org(id: str) -> Org: |
import axios from 'axios'; | |
let signal = axios.CancelToken.source(); | |
/** | |
* returns if error is being caused by axios cancel | |
* @function | |
* @returns {Boolean} - true if the error caused by canceling the request | |
*/ | |
const areRequestsCanceled = err => { |
/* | |
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp | |
server, but for some reason omit a client connecting to it. I added an | |
example at the bottom. | |
Save the following server in example.js: | |
*/ | |
var net = require('net'); |
const problem = { | |
start: {A: 5, B: 2}, | |
A: {C: 4, D: 2}, | |
B: {A: 8, D: 7}, | |
C: {D: 6, finish: 3}, | |
D: {finish: 1}, | |
finish: {} | |
}; | |
const lowestCostNode = (costs, processed) => { |
//from http://www.saltycrane.com/blog/2015/12/switching-emacs-vim-actually-spacemacs/ | |
Useful Spacemacs commands | |
SPC q q - quit | |
SPC w / - split window vertically | |
SPC w - - split window horizontally | |
SPC 1 - switch to window 1 | |
SPC 2 - switch to window 2 | |
SPC w c - delete current window |
Sometime when we need a specific way to interact with the phone or operator system which is various different between iOS and Android, that when we need to lean that responsibility to the OS it self.
In RN, most of the logic and UI, in the best way, must be consistent between platforms. So, In an advance level of bringing best user experience to end user, we need to create native module, that mean the leaning the logic to the Native Part. There are ton of article out there showing why and when we need to create a native module, I won't dive into explanation again. Instead, I will show you how can we create a native module that could be used in React native code. That mean, you write your Objective-C/Java code, and import and run it as a module in Javascript Code.
I will show you here the most basic way to create the most basic library, called: open https://google.com. It means, I want to open Google by using the default iOS/Android browser in a native way.
I'm learning about SOPS and setting it up as my preferred mechanism for storing secrets. Here are my notes.
It’s security mechanism is that we (i.e. client) use a PUBLIC key from the receiver (i.e. server) and encode it with a random key (I’m saying nonce but it could be reused)
This varies from RSA and SSH because the server uses a PUBLIC key to identify the client.
Web of trust operates by still using PGP (i.e. encoding with recipient’s public key) but additionally, we can encrypt/sign the data as our own by signing it with the client’s private key.
This means the recipient will initially decrypt via our (i.e. client’s) public key (verifying the source) and then decrypting via their (i.e. server’s) private key to get the data.
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers