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
package jsonbench | |
import ( | |
"database/sql" | |
"fmt" | |
"math/rand" | |
) | |
var ( | |
jsonPattern = "{\"value\": \"%s\"}" |
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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func containsAny(data interface{}, element ...interface{}) bool { | |
rVal := reflect.ValueOf(data) | |
switch rVal.Kind() { |
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
// Package internal ... | |
package internal | |
import ( | |
"fmt" | |
"github.com/go-sql-driver/mysql" | |
"golang.org/x/crypto/ssh" | |
"net" | |
) |
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
#!/bin/zsh | |
specialBranches=("master" "uat" "test" "release") | |
echo "\u001b[31mScanning released local branches...\n--------------------------------------------------------\u001b[0m" | |
releasedLocalBranches=() | |
for branch in $(git branch) | |
do | |
git show-ref -s --heads $branch | xargs git branch --contains | grep master > /dev/null | |
if [[ $? -eq 0 && ! " ${specialBranches[@]} " =~ " ${branch} " ]]; then |
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
next_xid = 1 | |
active_xids = set() | |
records = [] | |
class TransactionConflictError(RuntimeError): | |
pass | |
def new_transaction(): |
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 CryptoJS = require("crypto-js"); | |
var Property = require('postman-collection').Property; | |
var now = new Date(); | |
var timestampNow = parseInt(now.getTime() / 1000); | |
pm.collectionVariables.set("timestamp", timestampNow); | |
var host = pm.collectionVariables.get("host"); | |
var path = pm.request.url.getPath(); | |
var requestURL = host + path; |
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
==================== Supported Methods ====================== | |
['supervisor.addProcessGroup', 'supervisor.clearAllProcessLogs', 'supervisor.clearLog', 'supervisor.clearProcessLog', 'supervisor.clearProcessLogs', 'supervisor.getAPIVersion', 'supervisor.getAllConfigInfo', 'supervisor.getAllProcessInfo', 'supervisor.getIdentification', 'supervisor.getPID', 'supervisor.getProcessInfo', 'supervisor.getState', 'supervisor.getSupervisorVersion', 'supervisor.getVersion', 'supervisor.readLog', 'supervisor.readMainLog', 'supervisor.readProcessLog', 'supervisor.readProcessStderrLog', 'supervisor.readProcessStdoutLog', 'supervisor.reloadConfig', 'supervisor.removeProcessGroup', 'supervisor.restart', 'supervisor.sendProcessStdin', 'supervisor.sendRemoteCommEvent', 'supervisor.shutdown', 'supervisor.signalAllProcesses', 'supervisor.signalProcess', 'supervisor.signalProcessGroup', 'supervisor.startAllProcesses', 'supervisor.startProcess', 'supervisor.startProcessGroup', 'supervisor.stopAllProcesses', 'supervisor.stopProcess' |
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
data = [{'id': 1, 'value': 1}, {'id': 2, 'value': 2}, {'id': 2, 'value': 3}, {'id': 1, 'value': 4}] | |
for id, ele in groupby(data, key=lambda e: e['id']): | |
print "id: %d" % id | |
print "values: %s" % list(ele) | |
# => id: 1 | |
# => values: [{'id': 1, 'value': 1}] | |
# => id: 2 | |
# => values: [{'id': 2, 'value': 2}, {'id': 2, 'value': 3}] | |
# => id: 1 |
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
from django.db.models import Count | |
Model.values('pickup_plan_id').annotate(picked_count=Count('pickup_plan_id')).filter(picked_count__lt=2) | |
# SELECT | |
# `model`.`pickup_plan_id`, | |
# COUNT(`model`.`pickup_plan_id`) AS `picked_count` | |
# FROM | |
# `model` | |
# WHERE |
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
# Allow access only localhost by port 1991 | |
sudo iptables -A INPUT -i lo -p tcp --dport 1991 -j ACCEPT | |
sudo iptables -A INPUT -p tcp --dport 1991 -j DROP |
NewerOlder