Skip to content

Instantly share code, notes, and snippets.

@pastleo
pastleo / chrome bookmark to import jQuery
Last active January 2, 2016 07:59
Somehow just need jQuery to do something (dirty)...
javascript: var jQueryScriptSourceURL='//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'; var jQueryScript=document.createElement('script'); jQueryScript.setAttribute('src',jQueryScriptSourceURL); if(document.getElementsByTagName('head').item(0)==null) document.getElementsByTagName('html').item(0).appendChild(document.createElement('head')); jQueryScript=document.getElementsByTagName('head').item(0).appendChild(jQueryScript); varjQueryScriptLoadCompleted=function(){}; jQueryScript.onload=function(jQueryScriptLoadEvent){ try{ console.log('Self test ...$("head").html()=\n'+$("head").html()); console.log("jQueryScript loaded!"); jQueryScriptLoadCompleted(); }catch(exception){ console.log('Fatal Error:'+exception.message); if(!jQueryScriptLoadEvent.returnValue) console.log('Loading jQueryScript was failed!'); } }; jQueryScriptLoadCompleted=function(){ console.log("要執行的JS和jQuery請定義在jQueryScriptLoadCompleted裡\n同時也請注意在網址上加入要執行的JS是不能加註解的\nLet's party!!!"); };
@pastleo
pastleo / using js to import js
Created January 5, 2014 20:23
useful function when you need to import js without html...
function loadJS(url,loadFinished){
if(typeof loadFinished != 'function')
loadFinished=function(){};
rs_nav.message("JS from "+url+" start to load...");
var JS = document.createElement('script');
JS.setAttribute('src', url);
if (document.getElementsByTagName('head').item(0) == null)
document.getElementsByTagName('html').item(0).appendChild(document.createElement('head'));
@pastleo
pastleo / SelectorInBadBrowser
Last active January 4, 2016 18:49
"Some" old browser just dont support useful selector, this can somehow change the situation
// For browsers that dont have getElementsByClassName
if(!document.getElementsByClassName){
document.getElementsByClassName = function(className, element){
var children = (element || document).getElementsByTagName('*');
var elements = new Array();
for (var i=0; i<children.length; i++){
var child = children[i];
var classNames = child.className.split(' ');
for (var j=0; j<classNames.length; j++){
if (classNames[j] == className){

Recommend Mac SoftWare

粗體為現在有安裝的軟體,一般則為已移除或是未安裝的軟體。

System

  • Alfred 2 - 熱鍵、Spotlight
  • coconutBattery - 電池記錄
  • iTerm - 比Terminal更好用的Console
  • Keka - 解壓縮軟體
  • TeamViewer - 遠端控制。
@pastleo
pastleo / 在 Windows 用 Vagrant 快速建立你的 Linux 環境.md
Last active April 10, 2023 14:13
在 Windows 用 Vagrant 快速建立你的 Linux 環境

在 Windows 用 Vagrant 快速建立你的 Linux 環境

Vagrant 是啥?

Vagrant 幫助你秒建虛擬機,甚至幫你安裝軟體到這個虛擬機,讓你躺著獲得測試環境

為何要用虛擬機

這樣一來,

@pastleo
pastleo / 台中前端社群_小聚#2.md
Created May 19, 2014 16:25
台中前端社群_小聚#2_筆記

台中前端社群_小聚#2

原來要自我介紹

jQuery Validation

  • 後端必要地需要驗證,但前端需要分擔這份工作
  • 使用方法: documtent
  • 基本用法

$(".selector").validate({

@pastleo
pastleo / Preferances.sublime-settings
Created June 9, 2014 20:34
My Preference.sublime-settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/PastLeoFaviColor1.tmTheme",
"detect_indentation": true,
"draw_minimap_border": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 12,
"highlight_line": true,
@pastleo
pastleo / 中興資工招生影片程式碼.sh
Last active August 29, 2015 14:03
中興大學資訊工程學系2014招生影片內所使用的BASH程式碼
#!/bin/bash
process_bar()
{
for (( i = 0; i < 50; i++ )); do
printf "\r["
for (( j = 0; j < 50; j++ )); do
if [ "$i" -ge "$j" ]; then
printf "#"
else
printf " "
@pastleo
pastleo / COSCUP_2014.md
Last active August 29, 2015 14:04
COSCUP 2014 筆記記錄

COSCUP 2014

Hackfoldr

Day 1

  • 盡量在8:30左右到達會場
  • 09:10 — 10:00 : Maker 《自造世代》
  • 一大堆"硬體"開源人
@pastleo
pastleo / Create_GIF_using_commandline.md
Last active August 29, 2015 14:04
Create GIF using commandline

Create GIF using commandline

There is a super image converter for commandline: ImageMagick,it has a lot of image convertion tools. You can install it using brew,just brew install ImageMagick (if you are using mac with brew) ^_^

  1. First, I bet you must resize your imgs,here is the example
mogrify -resize 640x480 *.jpg