Skip to content

Instantly share code, notes, and snippets.

View shadeven's full-sized avatar

Steven Wu shadeven

View GitHub Profile
  • Pull changes from develop branch for all submodules.

git submodule foreach git "pull origin develop"

  • Push changes from branch PD2-376-html-emails for all submodules.

git submodule foreach "git push origin PD2-376-html-emails"

package com.e3learning.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
@org.codehaus.jackson.annotate.JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public interface JPAEntity {
}
public function __construct() {
parent::__construct();
$this->load->model('public/rhd_model');
$down_notice = $this->rhd_model->db_chk_notice();
if($down_notice != false) {
if ($down_notice['message'] == '')
$down_notice['message'] = 'The thesis system is temporarily unavailable, please try again later.';
$errdata['message'] = $down_notice['message'];
$errdata['heading'] = "Notice";
$this->load->view('reading_listmgr/showerror_view', $errdata);
// Anonymous function
const anonymous = function(value) {
console.log(value);
return value;
}
anonymous('Steven');
// Named function
function named(value) {
console.log(value);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://fb.me/react-with-addons-0.14.3.js"></script>
<script src="https://npmcdn.com/expect/umd/expect.min.js"></script>
<title>JS Bin</title>
</head>
<body>
@shadeven
shadeven / Module.js
Created May 4, 2017 05:10
ES6 export
export default MyModule = () => console.log('foo')
import MyModule from './MyModule' //it works
import foobar from './MyModule' //it also works
export const MyModule = () => console.log('foo')
import MyModule from './MyModule' //returns empty object since there is no default export
import { MyModule } from './MyModule' //here it works because by exporting without 'default' keyword we explicitly exported MyModule
function add($num1, $num2) {
$num1 + $num2;
}
var_dump(add(2, 4));
function verify($value) {
if ($value > 1) {
return $value;
} else {
// good
module.exports = {
add(a,b) { return a+b }
}
// good
module.exports.subtract = (a,b) => a-b
// valid
@shadeven
shadeven / number.php
Last active April 20, 2017 04:44
The snippet illustrates the numeric conversion in PHP.
$string_value = '66.67454545';
$non_num_string = '66.67454545TEST';
$non_num_float = floatval($non_num_string);
var_dump($non_num_float);
echo '<br>';
$float_value = floatval(number_format($string_value, 2));
var_dump($float_value);
echo '<br>';
@shadeven
shadeven / App.js
Last active February 20, 2017 07:28
This is a simple React app. The counter increases by 1 when the button is clicked.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class Button extends Component {
render() {
return (
<div>
<h1>{this.props.count}</h1>