Skip to content

Instantly share code, notes, and snippets.

@aloha1003
aloha1003 / gist:47285c267bbca39e7ff9e6d4ab3c5b30
Created September 8, 2016 01:27 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
def downLoadImage(region, imageObj):
s3 = boto3.resource('s3', region_name=region)
bucketName = str(imageObj["Bucket"])
objectName = str(imageObj["Object"])
key = s3.Bucket(bucketName) \
.Object(objectName)
saveFileName = '/tmp/'+objectName.replace('/', '__')
s3.meta.client.download_file(bucketName, objectName, saveFileName)
return saveFileName
String.prototype.format = String.prototype.f = function() {
var s = this,
i = arguments.length;
var compareStr = '';
var map = {};
if ( (arguments.length == 1) && (typeof arguments[0] === 'object')) {
for (var prop in arguments[0]) {
key = prop;
compareStr += key+'|';
map['{'+key+'}'] = arguments[0][prop];
String.prototype.format = String.prototype.f = function() {
var s = this,
i = arguments.length;
while (i--) {
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
}
return s;
};
//UseAge
@aloha1003
aloha1003 / gist:cb074b94a625e6790ccbde48fde2f5e2
Created July 28, 2016 15:43 — forked from mgedmin/gist:9547214
Setting up a Jenkins slave on Linux
# This is how you add a Jenkins slave
# On master:
sudo -u jenkins -H ssh-keygen
# On slave
adduser --system --group --home=/var/lib/jenkins-slave --no-create-home --disabled-password --quiet --shell /bin/bash jenkins-slave
install -d -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave
@aloha1003
aloha1003 / Logstash configure for parse json from text file
Created June 22, 2016 02:58
Logstash configure for parse json from text file
filter {
grok {
match => { "message" => "^\[%{TIMESTAMP_ISO8601:datetime}\]\s+%{DATA:env}\s+%{LOGLEVEL:loglevel}+\:%{GREEDYDATA:log_msg}" }
add_field => {
"received_at" =>"%{datetime}"
"enviroment" => "%{env}"
"log_level" => "%{loglevel}"
}
}
var fs = require('fs'),
http = require('http'),
https = require('https'),
express = require('express'),
token = '',
bodyParser = require('body-parser'),
request = require('request');
var port = 443;
use \App\Model\ObjectForTest as ObjectForTest;
class Main() {
function test() {
$ary = [];
array_map(array('ObjectForTest', 'fun'), $ary); //回報錯誤
array_map(array('\App\Model\ObjectForTest', 'fun'), $ary); //正常
}
}
<div class="areaA">
<select ng-model="areaACountry" ng-options="citys for (citys, areaACountry) in zipCodes" ></select>
<select ng-model="areaATown"
ng-options="areas for (areas, zipcode) in areaACountry" ></select>
</div>
<div class="areaB">
<input type="checkbox" id="areaBAsAreaA" ng-checked="areaBAsAreaA()" />與AreaA相同內容<br />
<select ng-model="areaBCountry" ng-options="citys for (citys, areaBCountry) in zipCodes" ></select>
<select ng-model="areaBTown"
ng-options="areas for (areas, zipcode) in areaBCountry" ></select>
1. find and add contacts by email or phone number (Important)