Skip to content

Instantly share code, notes, and snippets.

@ptmt
ptmt / postgres-nas-2016.md
Created December 15, 2018 11:45
Setting up Postgres on NAS

Network storages are really handy when it comes to a lot of disk space. Cheaper disk space available, RAID and after all it's a small server, 1GHz/256MB in my case. I wish I had NAS before.

I bought the one from Western Digital, MyCloud EX2Ultra to be specific, and one of the main reason for that is being able to work with a huge database. Consider Postgres, which runs on my Mac with 256GB, so any database larger than XX Gb is large enough to worry about. You can solve this problem with cloud, but what about 2TB database? 20TB?

My first attempt was about mount drive manually and create the database there:

mount -t smbfs smb://MyCloudEX2Ultra/Public/db db
@ptmt
ptmt / add_flow.sh
Created August 2, 2017 06:54 — forked from djoeman84/add_flow.sh
Add flow to all your JS files
#!/bin/bash
# Based on http://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
find . -type f -iname "*.js" -print0 | while IFS= read -r -d $'\0' i;
do
added=$(grep -q @flow $i)
if [[ (!$added) && ( $i != *"node_modules"* ) ]]
then
(echo "" & echo "/* @flow */") > flowificator
cat flowificator $i >$i.new && mv $i.new $i
@ptmt
ptmt / rn-cli.config.js
Last active August 1, 2017 12:18
Symlinks workaround with wml
const { execSync, spawn } = require('child_process');
if (process.argv.indexOf('start') > -1) {
console.log('Setting up wml');
const wmlBin = path.join(__dirname, 'node_modules/.bin/wml');
try {
console.log(execSync(`${wmlBin} rm all`).toString());
console.log(
execSync(
`${wmlBin} add ${__dirname}/../module ${__dirname}/node_modules/module --skip-prompt=true`
@ptmt
ptmt / rn-cli.config.js
Last active March 8, 2020 16:21
rn-cli.config.js
const path = require('path');
// Don't forget to everything listed here to `package.json`
// modulePathIgnorePatterns.
const sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
'downstream/core/invariant.js',
/website\/node_modules\/.*/,
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.

Proposal for lightning talk at Reactive Conference.

===

Use case for react-native-macos

React Native for macOS (a.k.a React Native Desktop) started as an experiment a year ago, just out of curiousity and the active stage of development also took place during the previous Reactive conference right in the hotel room in Bratislava.

5 minutes talk about why you probably haven't heard about any real desktop application based on RN, and for what kind of applications it might be perfect fit.

@ptmt
ptmt / Utils.m
Created August 16, 2015 06:47
Taking screenshot on react-native
- (NSURL *) takeScreenshot:(NSString *)imageName {
UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
UIGraphicsBeginImageContextWithOptions(root.view.bounds.size, NO, [UIScreen mainScreen].scale);
[root.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
NSData *imgData = UIImagePNGRepresentation(image);
UIGraphicsEndImageContext();
@ptmt
ptmt / index.ios.js
Created July 20, 2015 10:16
0.8.0rc2 - rounded View issue
/* @flow */
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Animated
} = React;
@ptmt
ptmt / generate_assets.js
Last active August 24, 2016 15:23
node --harmony utils/generate_images.js
'use strict';
const IMAGES_DIR = './images'
const ASSETS_DIR = './iOS/Images.xcassets'
const EXTENSIONS = ['jpg', 'jpeg', 'png']
var fs = require('fs')
var gm = require('gm')
function convertAndCopy(source, scaleFactor, imageName, imageExt) {
let per = scaleFactor === 3 ? '100%' : scaleFactor === 2 ? '50%' : '25%'
@ptmt
ptmt / macOS-arm-setup.sh
Last active February 4, 2022 09:11
Setting up fresh macOS
# 1. Install Brew (warning: at least read install at first)
cat "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# 2. Install Oh-my-zsh (warning: at least read install.sh at first)
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | cat
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
# 4. Install brew packages
brew install mas # appstore done right