Skip to content

Instantly share code, notes, and snippets.

View kosinix's full-sized avatar

Kosinix kosinix

  • Philippines
View GitHub Profile
@kosinix
kosinix / user.js
Created July 14, 2019 13:51
Express - Mongoose: Basic user table with password hash and checking methods.
//// Core modules
const crypto = require('crypto');
const util = require('util');
//// External modules
const mongoose = require('mongoose');
//// Modules
const randomBytesAsync = util.promisify(crypto.randomBytes);
@kosinix
kosinix / d.js
Created June 22, 2019 12:26
Kinabukasan ni Daggy
// Modules
const express = require('express')
const mysql = require('mysql')
const bodyParser = require('body-parser')
// Settings
const port = 3000
// Express
const app = express()
@kosinix
kosinix / win.md
Created April 20, 2018 00:04
Disable Taskbar Grouping Windows 10 for Power User

Disable Taskbar Grouping Windows 10 for Power User

Applies to inactivated windows too

Regedit

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
  • if it doesn't already exist, make a new DWORD value first (32 bit) and name it TaskbarGlomLevel
  • value hexadecimal 2
@kosinix
kosinix / bitsbytes.md
Last active April 8, 2018 08:09
Quick intro to binary if you eat binary for dinner

1 hex (aa) = 1 byte = 8 bits (1010 1010)

Name Size
bit 1 bit
nybble 4 bits
byte 8 bits
hex 8 bits or 1 byte
halfword 16 bits
@kosinix
kosinix / gitgotcha.md
Created December 18, 2017 08:00
git gotcha

Save vim commit message

Press ESC to make sure you are out of the edition mode and then type:

:wq

Delete remote branch

@kosinix
kosinix / gotcha.js
Last active October 29, 2017 08:51
JS promise API gotchas
function errorFunction(){
return Promise.reject('Reject value.');
}
function goodFunction(error=false){
return Promise.resolve('Resolved value.');
}
// Example 1. One level
goodFunction().then(function(ok){
console.log('First "then" called. Value: ', ok);
@kosinix
kosinix / excerpt.php
Created June 29, 2017 04:51
Read more that ends in sentence or exact words.
<?php
add_filter( 'the_content', 'my_the_content_filter', 22 );
function my_the_content_filter( $content ) {
if ( is_home() || is_archive() || is_search() ){
// Mode word
$mode = 'sentence'; // word or sentence
$count = 11;
/*
Theme Name: Turbo Surfing
Theme URI: #
Author: Team Perth
Author URI: #
Description: A theme for turbosurfing.com.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: turbosurfing
@kosinix
kosinix / Calendar formulas
Last active June 9, 2017 07:39
Formula for displaying days in a Gregorian calendar month
prefixLength - The number of pads before the first calendar day
suffixLength - The number of pads after the last calendar day
monthFirstWeekDay - The weekday of first month day. int 0-6 where 0 is Sunday and 6 is Saturday
monthLastWeekDay - he weekday of last month day. int 0-6 where 0 is Sunday and 6 is Saturday
calendarWeekStart - The weekday to which the calendar days start. int 0-6 where 0 is Sunday and 6 is Saturday
Pseudocode:
prefixLength = monthFirstWeekDay - calendarWeekStart
@kosinix
kosinix / doc.md
Last active April 20, 2017 07:44
Cycle2 event order of exec

Init

  • cycle-bootstrap
  • cycle-slide-added
  • cycle-pre-initialize
  • cycle-initialized
  • cycle-post-initialize
  • cycle-update-view

Transition