This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
http = require('http'), | |
https = require('https'), | |
express = require('express'), | |
token = '', | |
bodyParser = require('body-parser'), | |
request = require('request'); | |
var port = 443; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
//do something | |
} catch (\Exception $ex){ | |
//Write to Log | |
echo $ex->getMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Enter your code here, enjoy! | |
function arrayListPointer(...$index): Closure{ | |
$item = array_shift($index); | |
$composeIndex = count($index) > 0 ? arrayListPointer(...$index) : function($x) { | |
return $x; | |
}; | |
return function($x) use ($item, $composeIndex) { | |
return '['.$item.']'.$composeIndex($x); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Model extends BaseModel { | |
public $defaultRuleAry = []; //預設規則 | |
public function validation() { //驗證輸入 | |
//根據 $this->defaultRuleAry 來驗證 | |
return true; | |
} | |
public function save(array $options = array()) |