Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
Working from home

Nay Zaw Oo nayzawoo

🐢
Working from home
View GitHub Profile
@nayzawoo
nayzawoo / postman.js
Created Jul 5, 2019 — forked from regniblod/postman.js
Postman pre-request script to get a new JWT token before each request
View postman.js
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 Mar 21, 2019 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
View golang-tls.md

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 Aug 19, 2018 — forked from jakebathman/logslaravel.sh
Tail Laravel logs and filter out the stack traces
View logslaravel.sh
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 Jun 22, 2018 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.
View bash-colors.md

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 Mar 10, 2018 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel9k

Powerlevel9k

@nayzawoo
nayzawoo / README.md
Created Mar 7, 2018 — forked from rantav/README.md
Find slow queries in mongo DB
View README.md

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 Jan 30, 2018
AES-256 encryption and decryption in PHP and C#
View AES-256 encryption and decryption in PHP and C#.md

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 Jan 10, 2018
Fix Floating Point Error
View test.js
var floatNumber = 0.1
floatNumber * 2 //=> 0.2
floatNumber * 3 //=> 0.30000000000000004
((floatNumber * 10e10) * 3) / 10e10 // => 0.3
@nayzawoo
nayzawoo / gist:4e9bc8aa73e44ed1f3ba30727cdab6b6
Created Nov 30, 2017 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
View gist:4e9bc8aa73e44ed1f3ba30727cdab6b6
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 Nov 30, 2017 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
View gist:63d50ff8060242a142b3dcc4437f8c60
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