Skip to content

Instantly share code, notes, and snippets.

View dieunb's full-sized avatar
🎯
Focusing

Dieu Nguyen dieunb

🎯
Focusing
View GitHub Profile
@dieunb
dieunb / git-reset-author.sh
Created March 29, 2020 09:02 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@dieunb
dieunb / 01.1.lifecycle.rb
Created November 9, 2019 22:22 — forked from Aupajo/01.1.lifecycle.rb
Sockets in Ruby
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
@dieunb
dieunb / pr.md
Created March 12, 2018 09:19 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@dieunb
dieunb / reset-root-password
Last active March 7, 2018 07:42
Reset MySQL root password on Macos
If you don't remember the password you set for root and need to reset it, follow these steps:
Stop the mysqld server, this varies per install
Run the server in safe mode with privilege bypass
sudo mysqld_safe --skip-grant-tables;
In a new window connect to the database, set a new password and flush the permissions & quit:
mysql -u root
For MySQL older than MySQL 5.7 use:
{
"school_center": "Awesome academy",
"class_name": "Awesome Academy - PR1701",
"students": [
{
"name": "Hoang Lao Ta",
"age": "80",
"sex": "male"
},
{
@dieunb
dieunb / Dockerfile
Created November 4, 2017 15:02 — forked from RoyalIcing/Dockerfile
Rails 5.1 Dockerfile
FROM ruby:2.4-alpine
ENV PATH /root/.yarn/bin:$PATH
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base nodejs tzdata
RUN apk update \
&& apk add curl bash binutils tar gnupg \
&& rm -rf /var/cache/apk/* \
@dieunb
dieunb / docker-clean.md
Created November 4, 2017 14:36
Cleanup docker images and containers after failed builds

Cleanup docker images and containers after failed builds

Sometimes, there are some untagged images left behind after failed builds. In order to get rid of those, this script can be used.

#!/bin/bash
docker rm $(docker ps -aq)
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
@dieunb
dieunb / Rails5.1.0 + Devise4.3.0 + Bootstrap3 with Yarn
Last active October 12, 2017 07:37
rails5 + bootstrap3, font-awesome with Yarn
# Font-awesome
vi node_modules/font-awesome/scss/_variables.scss
# Replace
$fa-font-path: "../fonts";
# with this code
$fa-font-path: "font-awesome/fonts";
# Bootstrap
vi node_modules/gentelella/vendors/bootstrap/dist/css/bootstrap.css
<div class="db-modal-content"><form class="twofactor-account-form"><div class="codesbox"><p class="desc" style="display: block;">You can use these one-time backup codes to access your account.</p><p class="codesbox__error" style="display: none;">No backup codes left. Please generate more by clicking the button below.</p><div id="backup-code-list-edit-container"><ol class="twofactor-backup-list"><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">aysz ox91 </span></li><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">1cxp d5tj </span></li><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">fa3k l30x </span></li><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">d7gb fhxu </span></li><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">twta 994m </span></li><li class="twofactor-backup-list__item"><span class="twofactor-backup-list__code">s5if odwz </span></li><l
@dieunb
dieunb / 01-truthy-and-falsey-ruby.md
Created October 10, 2017 08:42 — forked from jfarmer/01-truthy-and-falsey-ruby.md
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update