Skip to content

Instantly share code, notes, and snippets.

@kaioken
kaioken / service.php
Created October 27, 2018 05:52
PhalconPHP Sentry.io Integration with Monolog
<?php
/**
* System Log using monolog
*/
$di->set('log', function ($file = 'debug') use ($config, $di) {
// Create the logger
$logger = new MonoLogger('GEWAER.API');
$client = new Raven_Client('https://' . getenv('SENTRY_RPOJECT_SECRET') . '@sentry.io/' . getenv('SENTRY_PROJECT_ID'));
@kaioken
kaioken / GitConfigHttpProxy.md
Created October 10, 2018 23:02 — forked from evantoli/GitConfigHttpProxy.md
Configure Git to use a proxy

Configure Git to use a proxy

##In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@kaioken
kaioken / books.md
Created October 10, 2018 20:36 — forked from abstractart/books.md
Free Programming Ebooks - O'Reilly Media. Codeship free ebooks here - https://bit.ly/2oQ0knQ
@kaioken
kaioken / change_primary_key.md
Created October 10, 2018 14:05 — forked from scaryguy/change_primary_key.md
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@kaioken
kaioken / read-access.sql
Created September 21, 2018 21:33 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@kaioken
kaioken / ip.md
Created June 14, 2018 14:20
Iptable open for a specific IP

##connec to the server from this ip to mysql

iptables -A INPUT -i eth0 -p tcp -d xx.xx.xx.xx --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT

##connect to the server from this ip

/sbin/iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX -j ACCEPT

@kaioken
kaioken / curl.ini
Created May 11, 2018 01:01 — forked from reinaldomendes/curl.ini
PHP Curl error 77 on ssl conections
;###################################################
; NOTE
;####################################################
; change your curl.ini on /etc/php.d/curl.ini
;
;This config was only tested on amazon AMI
;Please check if /etc/ssl/certs/ca-bundle.crt exists
;
;If you don't have the ca-bundle root certificate you
; can get this in
@kaioken
kaioken / postgres_queries_and_commands.sql
Last active April 11, 2018 20:36 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
Elastic Load Balancer, CloudFront and Let's Encrypt
@kaioken
kaioken / tips_increase_memory_limit_nodejs.js
Created December 18, 2017 00:31 — forked from motss/tips_increase_memory_limit_nodejs.md
[TIPS] Increase memory limit in Node.js
// By default the memory limit in Node.js is 512MB.
// This will cause FATAL ERROR- JS Allocation failed – process out of memory when processing large data files.
// It can be avoided by increasing the memory limit.
node --max_old_space_size=1024 server.js // increase to 1gb
node --max_old_space_size=2048 server.js // increase to 2gb
node --max_old_space_size=3072 server.js // increase to 3gb
node --max_old_space_size=4096 server.js // increase to 4gb
node --max_old_space_size=5120 server.js // increase to 5gb
node --max_old_space_size=6144 server.js // increase to 6gb