This file contains hidden or 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
func matches(for regex: String, in text: String) -> [String] { | |
do { | |
let regex = try NSRegularExpression(pattern: regex) | |
let results = regex.matches(in: text, | |
range: NSRange(text.startIndex..., in: text)) | |
return results.map { | |
String(text[Range($0.range, in: text)!]) | |
} | |
} catch let error { |
This file contains hidden or 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
$http.post('url', data, config) | |
.success(function (data, status, headers, config) { | |
if (data) { | |
console.log(data); | |
} | |
}) | |
.error(function (data, status, header, config) { | |
console.log(data.errorMsg); | |
}); |
This file contains hidden or 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
$interval(function() { | |
var d = Date(); | |
console.log('----- sending transaction 1 wei '+d+'------'); | |
}, 60000); |
This file contains hidden or 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
let matrixSize = 10 | |
for y in 0..<matrixSize { | |
var line = "" | |
for x in 0..<matrixSize { | |
let point = (x, y) | |
switch point { | |
case let (x, y) where x == y: | |
line.append("#") | |
case let (x, y) where y == matrixSize-1 || y == 0 || x == 0 || x == matrixSize-1: | |
line.append("#") |
This file contains hidden or 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
#create new node with json genesis | |
geth --datadir ./myDataDir --networkid 1114 init ./myGenesis.json console 2>> myEth.log | |
#start geth for ws without ipc support | |
nohup geth --datadir ./myDataDir --networkid 1114 --ws --wsorigins="*" --wsapi "db,eth,net,ssh,miner,web3,personal,admin" --rpc --rpcapi "web3,eth,personal,miner,net,txpool" --rpccorsdomain "*" --ipcdisable & | |
#geth attach without ipc | |
geth attach http://localhost:85451 | |
#geth transfer |
This file contains hidden or 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 data = $.param({ | |
attr1: $scope.attr1, | |
attr2: $scope.attr2 | |
}); | |
var config = { | |
headers : { | |
'Content-Type': 'application/x-www-form-urlencoded' | |
} | |
}; |
This file contains hidden or 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
require('dotenv').config(); | |
var http = require('http'); | |
var https = require('https'); | |
var fs = require('fs'); | |
const WebSocket = require('ws'); | |
Tail = require('tail').Tail; | |
var privateKey = fs.readFileSync('./key.pem', 'utf8'); | |
var certificate = fs.readFileSync('./cert.pem', 'utf8'); |
This file contains hidden or 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
// if user is running mozilla then use it's built-in WebSocket | |
window.WebSocket = window.WebSocket || window.MozWebSocket; | |
var connection = new WebSocket('wss://localhost:443', 'echo-protocol'); | |
connection.onopen = function () { | |
// connection is opened and ready to use | |
console.log('client opened socket'); | |
$scope.send(); | |
}; |
NewerOlder