Skip to content

Instantly share code, notes, and snippets.

View chibaye's full-sized avatar

chibaye chibaye

View GitHub Profile
@chibaye
chibaye / memorySizeOfObject.js
Created June 3, 2020 00:30
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@chibaye
chibaye / css-media-queries-cheat-sheet.css
Created May 20, 2020 11:01 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@chibaye
chibaye / simple_scrollbar_hover_effect.css
Created May 15, 2020 19:45 — forked from howar31/simple_scrollbar_hover_effect.css
Neat and clean scrollbar with hover transition effect CSS
// Scrollbar with Hover Transition Effect
.container::-webkit-scrollbar {
width: 14px;
}
.container::-webkit-scrollbar-thumb {
background-clip: content-box;
border: 4px solid transparent;
border-radius: 7px;
box-shadow: inset 0 0 0 10px;
}
//-------
public static final String BASE_URL = "https://lateralview.co";
public static final String HEADER_CACHE_CONTROL = "Cache-Control";
public static final String HEADER_PRAGMA = "Pragma";
private Context mContext;
//-------
@chibaye
chibaye / CreditCardFormatTextWatcher.java
Created May 8, 2020 20:37 — forked from danielesegato/CreditCardFormatTextWatcher.java
Android TextInputLayout with credit card mask
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.Spannable;
import android.text.TextWatcher;
@chibaye
chibaye / CreditCardEditText.java
Created May 8, 2020 20:05 — forked from alphamu/CreditCardEditText.java
A simple EditText view for use with Credit Cards. It shows an image of the credit card on the right hand side.
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.AppCompatEditText;
import android.util.AttributeSet;
import android.util.SparseArray;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@chibaye
chibaye / javascript-object-to-querystring.js
Created April 27, 2020 08:36 — forked from tjmehta/javascript-object-to-querystring.js
Object to Querystring - JavaScript, JS, JSON
function objectToQuerystring (obj) {
return Object.keys.reduce(function (str, key, i) {
var delimiter, val;
delimiter = (i === 0) ? '?' : '&';
key = encodeURIComponent(key);
val = encodeURIComponent(obj[key]);
return [str, delimiter, key, '=', val].join('');
}, '');
}
@chibaye
chibaye / nginx.conf
Created April 17, 2020 12:01 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@chibaye
chibaye / CSVtoJSON.js
Created April 3, 2020 09:39 — forked from Jonarod/CSVtoJSON.js
Parse CSV and convert it to JSON with ES6
function CSVToMatrix(csv,delimiter){
let matrix = [];
csv.split('\n').map( l => { l.trim() == "" ? 0 : matrix.push(l.trim().split(delimiter).map(v=>v.trim())) })
return matrix
}
function MatrixToJSON(matrix,from,to){
let jsonResult = []; from = from||0;
matrix.map((a,i) => {
let obj = Object.assign({}, ...matrix[0].map((h, index) => ({[h]: matrix[i][index]})))
@chibaye
chibaye / next_nginx.md
Created January 2, 2020 19:34 — forked from kocisov/next_nginx.md
How to setup next.js app on nginx with letsencrypt

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw