Skip to content

Instantly share code, notes, and snippets.

View stalniy's full-sized avatar
🏠
Working from home

Sergii Stotskyi stalniy

🏠
Working from home
View GitHub Profile
@igogrek
igogrek / How I stopped loving Angular.md
Last active April 2, 2024 03:00
How I stopped loving Angular

I've worked with AngularJS for many years now and still use it in production today. Even though you can't call it ideal, given its historically-formed architecture, nobody would argue that it became quite a milestone not only for evolution of JS frameworks, but for the whole web.

It's 2017 and every new product/project has to choose a framework for development. For a long time I was sure that new Angular 2/4 (just Angular below) will become the main trend for enterprise development for years to come. I wasn't even thinking of working with something else.

Today I refuse to use it in my next project myself.

@stalniy
stalniy / fix-browserify-wkwebview.js
Created August 5, 2017 20:28
Cordova hook to fix WK WebView and --browserify option (temporary workaround)
/**
* Just add this script as `after_build` and `after_prepare` hook in config.xml for ios platform.
*/
const { join } = require('path')
const fs = require('fs')
// TODO: Remove this after https://issues.apache.org/jira/browse/CB-11311 is fixed
module.exports = function(ctx) {
if (!ctx.opts.browserify) {
@waja
waja / create_debian-sys-maint_for_mysqladmin.sh
Last active April 18, 2022 18:57
Create 'debian-sys-maint' MariaDB user for use of mysqladmin. Just in case you can't use 'root' via 'unix_socket' plugin.
#!/bin/sh
MYSQLADMIN_CFG="/etc/mysql/mariadb.conf.d/90-mysqladmin.cnf"
# generate password
PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
# adjust /etc/mysql/debian.cnf (used as defaults file by system scripts)
sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
# create config file for mysqladmin itself (maybe not needed)
umask 066
cat > ${MYSQLADMIN_CFG} <<EOF
@valyala
valyala / README.md
Last active April 19, 2024 13:00
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@ravishtiwari
ravishtiwari / Appfile.rb
Last active April 30, 2020 23:17
Ionic Build IPA with Fastlane tool
app_identifier "com.yourorganization.mytodoapp" # The bundle identifier of your app
apple_id "<You Apple Id>" # Your Apple email address
# You can uncomment any of the lines below and add your own
# team selection in case you're in multiple teams
# team_name "CAMobileApp"
# team_id "Q2CBPJ58CA"
# you can even provide different app identifiers, Apple IDs and team names per lane:
# https://github.com/KrauseFx/fastlane/blob/master/docs/Appfile.md
@callumlocke
callumlocke / scale-canvas.ts
Last active April 12, 2024 03:25
How to fix a canvas so it will look good on retina/high-DPI screens.
/*
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed.
The following code makes an 800×600 canvas that is always as sharp as possible for the device.
You still draw on it as if it's the logical size (800×600 in this case), but everything just
looks sharper on high-DPI screens. Regular non-sharp screens are not affected.
*/
const width = 800
@traviskaufman
traviskaufman / jasmine-this-vars.md
Last active September 19, 2022 14:35
Better Jasmine Tests With `this`

Better Jasmine Tests With this

On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this object, and we've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test for us looked something like this:

describe('views.Card', function() {
# Here's the script I'll use to demonstrate - it just loops forever:
$ cat test.rb
#!/usr/bin/env ruby
loop do
sleep 1
end
# Now, I'll start the script in the background, and redirect stdout and stderr
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)