Skip to content

Instantly share code, notes, and snippets.

View adamhut's full-sized avatar

Yu Ting Huang adamhut

  • Shapeways
  • Los Angeles
View GitHub Profile
@adamhut
adamhut / fonts.js
Created August 8, 2019 17:17 — forked from JacobBennett/fonts.js
List all font styles being used on the page
var ret={};
$('*').each(function () {
var str = $(this).css('font-family');
str = str + ':' + $(this).css('font-weight');
str = str + ':' + $(this).css('font-style');
if (ret[str] ) {
ret[str] = ret[str] + 1;
} else {
ret[str] = 1;
}
@adamhut
adamhut / download_Chinese_file_name.php
Last active April 24, 2019 02:08
Laravel 下載中文檔名
// 在使用Storage::download 不能有ASCII以外的檔名,下載時以便下載時為中文檔名。
$filename = urlencode($filename);
$header=[
'Content-type' => 'application/force-download',
'Content-Transfer-Encoding' => 'Binary',
'Content-Disposition' => 'attachment;filename='.$filename,
];
@adamhut
adamhut / laravel-websockets-on-forge.md
Last active June 16, 2020 03:13
Laravel Websockets on Forge Note Using SSL

Step by Step to create a stand along Laravel Websocket Server

I can make the laravel-websocket works local and on forge without SSL. I want to make it work when it with SSL on Forge as well. I read some articles and the officeal documnet to make it work. The follwoing is my sernario.This take me a long to make it work. Thank Alex Bouma's article finaly make my case work.

Sernario

  • One stand alone Weksocket Server
@adamhut
adamhut / deployment_guide.md
Created April 3, 2019 13:14 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel

Setting Up Laravel in Ubuntu / DigitalOcean

Getting Started

  • Create droplet with Ubuntu 18.10
  • ssh root@[DROPLET IP ADDRESS]
  • Get password from your email
  • Change password on first login
  • adduser laravel
  • Enter password and other information
@adamhut
adamhut / error_blade_directive.php
Created March 29, 2019 13:24 — forked from calebporzio/error_blade_directive.php
A little Blade directive to make working with validation errors a bit nicer.
<?php
// Usage:
// Before
@if ($errors->has('email'))
<span>{{ $errors->first('email') }}</span>
@endif
// After:
@adamhut
adamhut / .vimrc
Created March 25, 2019 13:55 — forked from JeffreyWay/.vimrc
Laracasts: Vim Mastery - Episode 3 .vimrc progress
syntax enable
colorscheme desert
"-------------General Settings--------------"
set backspace=indent,eol,start "Make backspace behave like every other editor.
let mapleader = ',' "The default leader is \, but a comma is much better.
set number "Let's activate line numbers.
# Manually secure port 6379
sudo iptables -A INPUT -p tcp --dport 6379 -s xxx.xxx.xxx.xxx -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 6379 -j DROP
sudo iptables -L
# Save current firewall config
sudo iptables-save > /etc/iptables.conf
# Load iptables.conf on startup
sudo nano /etc/rc.local
@adamhut
adamhut / with-data-attributes.js
Created July 22, 2018 13:12 — forked from JeffreyWay/with-data-attributes.js
Vue Tooltips: Three Ways
import PopperTooltip from 'tooltip.js';
new Vue({
el: '#app',
mounted() {
document.querySelectorAll('[data-tooltip]').forEach(elem => {
new PopperTooltip(elem, {
placement: elem.dataset.tooltipPlacement || 'top',
title: elem.dataset.tooltip
@adamhut
adamhut / country_code.php
Created July 16, 2018 20:25
Counntry Code
<?php
return [
"AF"=>"Afghanistan",
"AX"=>"Aland Islands",
"AL"=>"Albania",
"DZ"=>"Algeria",
"AS"=>"American Samoa",
"AD"=>"Andorra",
"AO"=>"Angola",
"AI"=>"Anguilla",
@adamhut
adamhut / gist:18e7eb7323a4310a61be6c490d34c35c
Created May 26, 2018 15:19 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',