Skip to content

Instantly share code, notes, and snippets.

View adrianolsk's full-sized avatar

Adriano Skroch adrianolsk

  • Wealthsimple
  • Calgary, Canada
View GitHub Profile
@adrianolsk
adrianolsk / .setup_git_credentials.md
Last active September 18, 2018 14:53
git credentials

Using SSH The common approach for handling git authentication is to delegate it to SSH. Typically you set your SSH public key in the remote repository (e.g. on GitHub), and then you use that whenever you need to authenticate. You can use a key agent of course, either handled by your desktop environment or manually with ssh-agent and ssh-add.

To avoid having to specify the username, you can configure that in SSH too, in ~/.ssh/config; for example I have

Host git.opendaylight.org User skitt and then I can clone using

git clone ssh://git.opendaylight.org:29418/aaa

@adrianolsk
adrianolsk / add_remove_column_to_all_tables.sql
Last active August 6, 2018 23:50
PostgreSQL usefull scrips
--add
select
f_add_col(cast(tablename as text), 'created_at', 'timestamptz', 'now()')
from
pg_catalog.pg_tables
where
schemaname = 'public';
--drop
@adrianolsk
adrianolsk / docker-compose.yml
Created April 2, 2018 16:22
Create a Postgres docker container
PostgreSQL:
restart: always
image: postgres:9.6-alpine
container_name: postgres
ports:
- "5432:5432"
environment:
- DEBUG=false
- POSTGRES_USER=postgres_or_another
- POSTGRES_PASSWORD=something_secure
@adrianolsk
adrianolsk / app.js
Created March 25, 2018 15:38 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@adrianolsk
adrianolsk / kill_by_port.sh
Created January 7, 2018 13:19
Kill a process by port
#This will print you PID of process bound on that port.
fuser 8080/tcp
#And this will kill that process.
fuser -k 8080/tcp
#Works on Linux only. More universal is use of lsof -i4 (or 6 for IPv6).
#To list any process listening to the port 8080:
lsof -i:8080
@adrianolsk
adrianolsk / adb_commands
Created January 5, 2018 18:44
ADB Commands - React Native reload
#change the path of the adb
#Open menu and press reload
/Users/imac/Library/Android/sdk/platform-tools/adb shell input keyevent 82
/Users/imac/Library/Android/sdk/platform-tools/adb shell input keyevent KEYCODE_ENTER
@adrianolsk
adrianolsk / mongodb.md
Created December 4, 2017 13:59
Today I learned

#Capped Collections

Overview

Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

@adrianolsk
adrianolsk / redirect_browser_language.nginx
Created December 1, 2017 14:25 — forked from varnav/redirect_browser_language.nginx
Nginx can redirect to language subsite based on browser language
map $http_accept_language $index_redirect_uri {
default "/en/";
"~(^|,)en.+,ru" "/en/";
"~(^|,)ru.+,en" "/ru/";
"~(^|,)en" "/en/";
"~(^|,)ru" "/ru/";
}
location = / {
return 302 $index_redirect_uri;
/* SINPPET FOR DELETED & DELETED AT SUPPORT IN KNEX.JS
inspired from Sequlize.js 'paranoid' schema option,
don't delete rows from database, ever.
*/
/* In Table Definition */
knex.schema.createTable('TABLE_NAME', function(table) {
table.boolean('deleted').defaultsTo(false).notNullable();
table.dateTime('deleted_at');
@adrianolsk
adrianolsk / page.component.ts
Last active July 5, 2024 14:30
Angular Routing with Hashtag to page anchor
export class PageComponent implements OnInit {
private fragment: string;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.route.fragment.subscribe(fragment => {
if (fragment) {