Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<style>
html, body {
margin: 0;
height: 100%;
/*
1) 打開 https://popcat.click
2) 打開主控台 (F12 / command + options + i)
3) 複製貼上 + enter
*/
var event = new KeyboardEvent('keydown', {
key: 'g',
ctrlKey: true
@marsnow
marsnow / Fade.txt
Created October 2, 2019 17:52
music fade in and fade out
<audio controls="controls" id="audioEl">
<source src="http://datashat.net/music_for_programming_41-sunjammer.mp3" />
</audio>
<button id="fadeoutbutton">Fadeout</button>
<button id="fadeinbutton">
Fadein
</button>
var audio = document.getElementById('audioEl');
@marsnow
marsnow / mysql.sh
Created May 10, 2019 08:12
upgrade mamp mysql
tar xfvz mysql-5.7*.tar.gz
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
sudo rsync -arv --progress /Applications/MAMP ~/Desktop/MAMP-Backup
echo "copy bin"
const temp = {
"data":
{
"id": "1",
"type": "budget_template",
"attributes":
{
"name": "Thuggin",
"typing": "main",
"enabled": true
var phpTimestamp = 1513047372;
moment.unix(phpTimestamp).utc().format('YYYY/MM/DD')
<?php
class Log
{
private $type = '';
public function setLog($type, $message)
{
$now = new DateTime('now');
$defaultLog = array(
'destination' => 'logs/'.$now->format('Y-m-d')."_$type.log",
<?php
class Database
{
private $servername;
private $username;
private $password;
private $dbname;
private $conn;
<?php
/***** config *****/
$cols = [
//[type, 'dbCols', 'jsonName']
['s', 'source', null],
['s', 'photo_id', 'photo_id'],
['s', 'user_id', 'owner_id'],
['d', 'latitude', 'latitude'],
['d', 'longitude', 'longitude'],
['s', 'photo_title', 'photo_title'],
@marsnow
marsnow / example.php
Created June 11, 2016 06:11 — forked from jaceju/example.php
物件導向基礎與物件導向設計入門
<?php
abstract class Database
{
public function __construct()
{
$this->connect();
}
abstract public function connect();