Skip to content

Instantly share code, notes, and snippets.

View daltonnyx's full-sized avatar
🦥

Quy Truong daltonnyx

🦥
  • Saigon Technology
  • Da Nang
View GitHub Profile
@daltonnyx
daltonnyx / form-field-json-cookies.js
Created March 2, 2017 09:06 — forked from zyphlar/form-field-json-cookies.js
Storing & retrieving form fields in a JSON cookie
/* Storing & retrieving form fields in a JSON cookie
* copyright Will Bradley, 2012, released under a CC-BY license
*
* Change all instances of "myform" as necessary.
* Cookie will be stored under the current URL, but
* it won't include any hidden fields, etc.
*/
function setCookie(c_name,value,expireminutes)
{
@daltonnyx
daltonnyx / qtranslate_widget.php
Created April 10, 2017 07:09 — forked from corellian/qtranslate_widget.php
Wordpress qTranslate-X language selector shortcode
/**
* Language Selector Shortcode
*/
function qtranxf_generateLanguageSelectorShortcode() {
global $q_config;
if(is_404()) $url = get_option('home'); else $url = '';
echo PHP_EOL.'<div style="text-transform: uppercase;" class="lang-sel sel-dropdown"><a href="#"><span>'.$q_config['language'].'</span></a><ul>'.PHP_EOL;
foreach(qtranxf_getSortedLanguages() as $language) {
@daltonnyx
daltonnyx / .tern-project
Created June 18, 2017 18:54 — forked from nisaacson/.tern-project
Use tern with vim for node.js development.
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
@daltonnyx
daltonnyx / gist:97fad31b0bd5f034deca73ccd86a922d
Created September 18, 2017 11:55 — forked from ichord/gist:9808444
demo of using pdf.js to extract pages to images
<script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script><html>
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/pdfjs-helloworld-v2/8598/edit
-->
<body>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
<input id='pdf' type='file'/>
<!-- Use latest PDF.js build from Github -->
@daltonnyx
daltonnyx / MySQL_macOS_Sierra.md
Created March 29, 2018 19:31 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@daltonnyx
daltonnyx / NoINotifyCreateWebHostBuilder_dotnetcore-2.x
Created February 13, 2020 12:14 — forked from babakontheweb/NoINotifyCreateWebHostBuilder_dotnetcore-2.x
A copy of Microsoft's WebHost.CreateDefaultBuilder but with IIS and FileWatcher dependencies removed for Linux environments. See https://github.com/aspnet/MetaPackages/blob/dev/src/Microsoft.AspNetCore/WebHost.cs#L148
/// <summary>
/// Initializes a new instance of the <see cref="WebHostBuilder"/> class with pre-configured defaults.
/// </summary>
/// <remarks>
/// The following defaults are applied to the returned <see cref="WebHostBuilder"/>:
/// use Kestrel as the web server and configure it using the application's configuration providers,
/// set the <see cref="IHostingEnvironment.ContentRootPath"/> to the result of <see cref="Directory.GetCurrentDirectory()"/>,
/// load <see cref="IConfiguration"/> from 'appsettings.json',
/// load <see cref="IConfiguration"/> from User Secrets when <see cref="IHostingEnvironment.EnvironmentName"/> is 'Development' using the entry assembly,
/// load <see cref="IConfiguration"/> from environment variables,
@daltonnyx
daltonnyx / reset-commit-author.md
Created January 26, 2021 09:21 — forked from marschhuynh/reset-commit-author.md
reset-commit-author
git filter-branch --force --commit-filter '
          if [ "$GIT_COMMITTER_EMAIL" = "wrong@email.com" ];
          then
                  export GIT_COMMITTER_NAME="New Name";
                  export GIT_AUTHOR_NAME="New Nam";
                  export GIT_COMMITTER_EMAIL="new@example.com";
                  export GIT_AUTHOR_EMAIL="new@example.com";
          fi;
 git commit-tree "$@"
@daltonnyx
daltonnyx / git.migrate
Created June 30, 2021 08:39 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.

Creating Neat .NET Core Command Line Apps

You can now read this on my (pretty) website! Check it out here.

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat