Skip to content

Instantly share code, notes, and snippets.

@iammac360
iammac360 / repl.js
Created October 21, 2020 09:01 — forked from vinbarnes/repl.js
Sequelize REPL
// Require the REPL module
// and models
let repl = require('repl').start({});
const models = require('./models');
// Make the `models` object
// a global variable in the
// REPL
repl.context.models = models;
@iammac360
iammac360 / crypto-aes-256-gcm-demo.js
Created July 8, 2020 07:30 — forked from rjz/crypto-aes-256-gcm-demo.js
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// Hint: the `iv` should be unique (but not necessarily random).
@iammac360
iammac360 / keybase.md
Created January 20, 2020 02:28
keybase.md

Keybase proof

I hereby claim:

  • I am iammac360 on github.
  • I am marksargento (https://keybase.io/marksargento) on keybase.
  • I have a public key ASArgOdUm77XT1sa3zCFj1tLF4um55ADOF5b-QGkxuKa_go

To claim this, I am signing this object:

@iammac360
iammac360 / kube-registry.yaml
Created September 24, 2019 06:00
Kube registry provision file
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@iammac360
iammac360 / api.js
Created June 25, 2018 10:53 — forked from pshoukry/api.js
React / Redux fetch from rails server with CSRF token
import _ from 'underscore';
import fetch from 'isomorphic-fetch'
class API {
getCSRFToken() {
return _.find(document.getElementsByTagName('meta'), (meta) => {
return meta.name === 'csrf-token'
}).content
}
@iammac360
iammac360 / brew-perms.sh
Created May 1, 2018 13:04 — forked from jaibeee/brew-perms.sh
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
@iammac360
iammac360 / refresh_union_view.sql
Last active March 31, 2017 09:29
Function to aggregate all data of a table from different postgresql schemas
CREATE OR REPLACE FUNCTION refresh_union_view(table_name text) RETURNS void AS $$
DECLARE
schema RECORD;
result RECORD;
sql TEXT := '';
BEGIN
FOR schema IN SELECT schema_name
FROM information_schema.schemata
WHERE schema_name
NOT IN ('pg_toast', 'pg_toast_temp_1', 'pg_temp_1', 'pg_catalog', 'information_schema')
@iammac360
iammac360 / facebok ip list
Created October 27, 2016 01:54 — forked from Whitexp/facebok ip list
facebook ip list
31.13.24.0/21
31.13.64.0/19
31.13.64.0/24
31.13.69.0/24
31.13.70.0/24
31.13.71.0/24
31.13.72.0/24
31.13.73.0/24
31.13.75.0/24
31.13.76.0/24
@iammac360
iammac360 / Singleton.js
Created June 4, 2016 04:50 — forked from you-think-you-are-special/Singleton.js
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: alexander@codeordie.ru
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
@iammac360
iammac360 / render-react-with-rxjs.md
Created May 15, 2016 04:50 — forked from zxbodya/render-react-with-rxjs.md
React with RxJS, reactive way :)

Observable React elements with RxJS

Note: if you want to skip history behind this, and just looking for final result see: rx-react-container

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.