Skip to content

Instantly share code, notes, and snippets.

View kuanhsuh's full-sized avatar
🏠
Working from home

Danny Huang kuanhsuh

🏠
Working from home
View GitHub Profile
const { post } = this.props;
if(!post){
return <div></div>;
}
To deal with undefined props
@kuanhsuh
kuanhsuh / gist:40c5b862ae5a897b60a4a308a449c193
Created April 29, 2017 00:03
Mixins - Set text Color light or dark depends on background color
@function set-text-color($color){
@if (lightness($color) > 50){
@return #000;
} @else {
@return #fff;
}
}
@kuanhsuh
kuanhsuh / gist:5d8453ec76fb415e07140e67bc555c19
Created April 29, 2017 00:06
Mixins-Add Borders( size, color, position) && add-background-color ( color)
@mixin add-border($size, $color, $position){
@if $position == 'all'{
border: $size solid $color;
} @else if $position == 'top' {
border-top: $size solid $color;
} @else if $position == 'bottom' {
border-bottom: $size solid $color;
} @else if $position == 'right' {
border-right: $size solid $color;
} @else if $position == 'left' {
@kuanhsuh
kuanhsuh / gist:5013fcace46c954534bbb46087d0a6f3
Last active May 2, 2017 05:04
CSS flexbox align center
display: flex;
justify-content:center;
align-items:center;
die('Query Failed' . mysqli_error($connection));
<?php echo substr(strip_tags($post->post_content), 0, 400); ?>
@kuanhsuh
kuanhsuh / elliecsstest
Last active January 9, 2018 02:18
ellie css test
.header
.logo
.links
nav
ul
li abc
li 123
@mixin size($w, $h: $w) {
height: $h;
@kuanhsuh
kuanhsuh / cloudSettings
Created February 28, 2018 14:34
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-02-28T14:34:43.924Z","extensionVersion":"v2.8.7"}
@kuanhsuh
kuanhsuh / promises
Created March 28, 2018 13:01
callback vs promises
function logWord(word){
setTimeout(function() {
console.log(word)
}, Math.floor(Math.random() * 100) + 1
// return value between 1 ~ 100
)
}
function logAll(){
logWord("A")
@kuanhsuh
kuanhsuh / arrcardio.js
Created March 31, 2018 14:29
Array Cardio
const users = [
{
id: 1,
name: 'Allison',
age: 4,
gender: 'female'
},
{
id: 2,
name: 'Derek',