Skip to content

Instantly share code, notes, and snippets.

View hoandang's full-sized avatar
👟
Roaming

Hoàn Đặng hoandang

👟
Roaming
  • Sydney, Australia
View GitHub Profile
@hoandang
hoandang / php-docker-ext
Created May 20, 2017 01:12
Complete list of php docker ext
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
@hoandang
hoandang / apache-conf.md
Last active April 1, 2024 06:46
Sample vhost configuration

Sample apache vhost configuration

Udate /etc/hosts or c:\windows\system32\drivers\etc\hosts file so that the new servername is mapped to 127.0.0.1

Apache config file changes document root

    DocumentRoot "/Users/hoan/www"
<Directory "/Users/hoan/www">
    #

Possible values for the Options directive are "None", "All",

@hoandang
hoandang / laravel-artisan-cheatsheet
Last active December 5, 2023 17:27
Laravel artisan cheatsheet
Available commands:
clear-compiled Remove the compiled class file
down Put the application into maintenance mode
env Display the current framework environment
help Displays help for a command
inspire Display an inspiring quote
list Lists commands
migrate Run the database migrations
optimize Cache the framework bootstrap files
serve Serve the application on the PHP development server
@hoandang
hoandang / get_rotate.js
Last active May 25, 2022 03:33
Javascript: get the angle by which the element is rotated
function getRotationAngle(target)
{
const obj = window.getComputedStyle(target, null);
const matrix = obj.getPropertyValue('-webkit-transform') ||
obj.getPropertyValue('-moz-transform') ||
obj.getPropertyValue('-ms-transform') ||
obj.getPropertyValue('-o-transform') ||
obj.getPropertyValue('transform');
let angle = 0;
@hoandang
hoandang / detect-uiscrollview-pos.md
Last active October 15, 2021 07:21
Detect uiscrollview position
@interface MyViewController : UIViewController<UIScrollViewDelegate>
@end

Then you can hook to the UIScrollView:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Set self as scroll view protocol

webView.scrollView.delegate = self;

@hoandang
hoandang / ruby: user.rb
Created January 20, 2013 06:53
A typical user model in rails
# Gem 'bcrypt-ruby'
# Generate User model with password_digest field
class User < ActiveRecord::Base
has_secure_password
attr_accessible :email, :name, :password, :password_confirmation
before_save { self.email.downcase! }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, uniqueness: {case_sensitive: false},
length: {maximum: 50}, format: { with: VALID_EMAIL_REGEX }
validates :name, presence: true, uniqueness: true
@hoandang
hoandang / docker-destroy-all.sh
Created July 8, 2017 12:37 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
/*
html2canvas 0.4.0 <http://html2canvas.hertzen.com>
Copyright (c) 2013 Niklas von Hertzen (@niklasvh)
Released under MIT License
*/
(function(window, document, undefined){
"use strict";
@hoandang
hoandang / struts2: persistence.xml
Created February 25, 2013 15:51
Struts 2 Persistence.xml OpenJPA
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="shop">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
@hoandang
hoandang / struts2: pom.xml
Created February 25, 2013 15:50
pom.xml Struts2 REST + OpenJPA + Jetty Server
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hoan</groupId>
<artifactId>Shop</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Shop Maven Webapp</name>
<url>http://maven.apache.org</url>