Skip to content

Instantly share code, notes, and snippets.

@ptmt
ptmt / macOS-arm-setup.sh
Last active Dec 11, 2020
Setting up fresh macOS
View macOS-arm-setup.sh
# 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
@ptmt
ptmt / rn-cli.config.js
Last active Mar 8, 2020
rn-cli.config.js
View 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\/.*/,
@ptmt
ptmt / postgres-nas-2016.md
Created Dec 15, 2018
Setting up Postgres on NAS
View postgres-nas-2016.md

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 Aug 2, 2017 — forked from djoeman84/add_flow.sh
Add flow to all your JS files
View add_flow.sh
#!/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 Aug 1, 2017
Symlinks workaround with wml
View rn-cli.config.js
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 / packages.config
Last active May 21, 2017
owin self-hosted blank project in F#
View packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Owin" version="1.1.0-beta2" targetFramework="net45" />
<package id="Microsoft.Owin.Hosting" version="1.1.0-beta2" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="Owin.Extensions" version="0.8.5" targetFramework="net45" />
<package id="Owin.Types" version="0.8.5" targetFramework="net45" />
</packages>
View ListViewExample.js
/**
* 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.
View REACTIVECONF2016-rnmacos.md

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 / generate_assets.js
Last active Aug 24, 2016
node --harmony utils/generate_images.js
View generate_assets.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 / flamp.fix.user.js
Created May 10, 2012
flamp.fix.user.js
View flamp.fix.user.js
// ==UserScript==
// @name flamp_fix
// @description save entire textarea in localStorage
// @version 0.1.0
// @namespace http://potomushto.com
// @include http://*.flamp.ru/*
// @match http://*.flamp.ru/*
// ==/UserScript==
// http://userscripts.org/scripts/show/89824