Skip to content

Instantly share code, notes, and snippets.

View MrRaindrop's full-sized avatar

Parzival MrRaindrop

View GitHub Profile
@MrRaindrop
MrRaindrop / angular-directive-filelistread.js
Last active August 29, 2015 14:01
angular自定义directive [filelistread]: 多文件上传,解决ngModel读不了上传文件的问题,并补充limit数量限制
/**
* usage:
* <form name="form">
* <input type="file" multiple name="uploads" filelistread limit="8" ng-model="uploads" />
* <label ng-show="form.uploads.$error.limit">上传文件数量限制最多为8个</label>
* </form>
*/
angular.module('testapp', []).directive("filelistread", function() {
return {
require: 'ngModel',
@MrRaindrop
MrRaindrop / angular-directive-filelistread2.js
Last active August 29, 2015 14:01
angular自定义directive [filelistread]: 多文件上传,解决ngModel读不了上传文件的问题,并补充limit数量限制
/**
* multiple files upload
* usage:
* <form name="form">
* <input type="file" multiple name="uploads" filelistread limit="8" ng-model="uploads" />
* <label ng-show="form.uploads.$error.limit">上传文件数量限制最多为8个</label>
* </form>
*/
angular.module('testapp', []).directive("filelistread", function() {
return {
@MrRaindrop
MrRaindrop / php: HTML_QuickForm2 to render a form and validate it.php
Created October 9, 2014 14:47
php: use HTML_QuickForm2 to render and valiate a form
<?php
require_once("HTML/QuickForm2.php");
require_once("HTML/QuickForm2/Renderer.php");
$languages = array(
"" => "Choose Languages:",
"C#" => "C#",
"JavaScript" => "JavaScript",
"Perl" => "Perl",
@MrRaindrop
MrRaindrop / php: upload file.php
Created October 11, 2014 01:06
php: upload file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testUpload</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data">
@MrRaindrop
MrRaindrop / php: upload file 2.php
Created October 11, 2014 13:56
php: upload file 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>testUpload2</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data">
@MrRaindrop
MrRaindrop / php: HTTP_Upload for file uploading.php
Created October 11, 2014 14:14
php: HTTP_Upload for file uploading
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>testHTTPUpload</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data">
@MrRaindrop
MrRaindrop / php: calculate subnet addresses.php
Created October 13, 2014 14:48
php: calculate subnet addresses
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>testCalcSubnet</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
IP Address:
<br/><input type="text" name="ip[]" size="3" maxlength="3" />
@MrRaindrop
MrRaindrop / php: session handler via mySQL.php
Last active August 29, 2015 14:07
php: session handler via mySQL
<?php
class MySQLSessionHandler {
private $_dblink;
private $_sessionName;
private $_sessionTable;
CONST SESS_EXPIRE = 3600;
import sublime
import sublime_plugin
import re
class CompactExpandCssCommand(sublime_plugin.TextCommand):
def run(self, edit, action='compact'):
rule_starts = self.view.find_all('\{')
rule_ends = self.view.find_all('\}')
@MrRaindrop
MrRaindrop / javascript: detect activity of web page
Created February 1, 2015 08:20
javascript: detect whether this web page is visible/activated or not
(function() {
var hidden = "hidden";
// Standards:
if (hidden in document)
document.addEventListener("visibilitychange", onchange);
else if ((hidden = "mozHidden") in document)
document.addEventListener("mozvisibilitychange", onchange);
else if ((hidden = "webkitHidden") in document)
document.addEventListener("webkitvisibilitychange", onchange);
else if ((hidden = "msHidden") in document)