Skip to content

Instantly share code, notes, and snippets.

@nayzawoo
nayzawoo / postman.js
Created July 5, 2019 08:13 — forked from regniblod/postman.js
Postman pre-request script to get a new JWT token before each request
pm.sendRequest({
url: pm.environment.get('url') + '/login_check',
method: 'POST',
header: {
'Content-Type': 'multipart/form-data',
},
body: {
mode: 'formdata',
formdata: [
{ key: '_email', value: pm.environment.get('email') },
@nayzawoo
nayzawoo / golang-tls.md
Created March 21, 2019 15:53 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@nayzawoo
nayzawoo / logslaravel.sh
Created August 19, 2018 20:05 — forked from jakebathman/logslaravel.sh
Tail Laravel logs and filter out the stack traces
tail -f -n 450 storage/logs/laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color
@nayzawoo
nayzawoo / bash-colors.md
Created June 22, 2018 22:18 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@nayzawoo
nayzawoo / iterm2-solarized.md
Created March 10, 2018 21:09 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@nayzawoo
nayzawoo / README.md
Created March 7, 2018 17:28 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

@nayzawoo
nayzawoo / AES-256 encryption and decryption in PHP and C#.md
Created January 30, 2018 09:08
AES-256 encryption and decryption in PHP and C#

AES-256 encryption and decryption in PHP and C#

PHP

<?php

$plaintext = 'My secret message 1234';
$password = '3sc3RLrpd17';
$method = 'aes-256-cbc';
@nayzawoo
nayzawoo / test.js
Created January 10, 2018 08:41
Fix Floating Point Error
var floatNumber = 0.1
floatNumber * 2 //=> 0.2
floatNumber * 3 //=> 0.30000000000000004
((floatNumber * 10e10) * 3) / 10e10 // => 0.3
@nayzawoo
nayzawoo / gist:4e9bc8aa73e44ed1f3ba30727cdab6b6
Created November 30, 2017 08:23 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@nayzawoo
nayzawoo / gist:63d50ff8060242a142b3dcc4437f8c60
Created November 30, 2017 08:23 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version