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
using System.Collections.Generic; | |
using Dapper; | |
using System.Text; | |
public class SQLQueryBuilder | |
{ | |
private readonly StringBuilder _sb = new StringBuilder(); | |
private readonly List<string> _fieldNames = new List<string>(); | |
private readonly List<string> _joins = new List<string>(); |
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
<!-- Custom caching policy for on HTTP POST for Azure API Management: | |
1. Policy looks in the Request body - 'cacheKey' property which then used as cache key. | |
Expected values are: <null>, ALL or NOEXPIRED | |
Defaults to ALL in case <null> | |
2. Cache expiration set to 60 seconds/1 minute | |
!--> | |
<policies> | |
<inbound> | |
<base /> |
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
const debug = require('./debug.config')('app:router-wrapper', console) | |
const wrapMethod = function (router, method) { | |
if (typeof router[method] !== "function") return false; | |
const original = router[method].bind(router); | |
debug('patching method: %o', method) | |
router[method] = (...args) => { | |
if (args.length < 2) return original(...args); | |
//first param can be string or array of strings, need to check and slice before get the middlewares array |
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
<?php | |
include '../funcoes.php'; | |
include '../conecta.php'; | |
function insert(&$insert_fields) | |
{ | |
$insert_sql = 'INSERT INTO fases ' | |
.' ('.implode(', ', array_keys($insert_fields)).')' | |
.' VALUES ('.implode(', ', array_values($insert_fields)).')'; |
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
/* use in a shell like robomongo / robo3t */ | |
db.getCollectionNames().forEach( | |
function(collection_name) { | |
db[collection_name].remove({}) | |
} | |
); |
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
int avoidObstacles(int[] inputArray) | |
{ | |
var jump = 2; | |
var max = inputArray.Max() + 1; | |
while (jump <= max) | |
{ | |
int multiplier = 1; | |
bool success = false; | |
while (true) | |
{ |
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
int arrayMaximalAdjacentDifference(int[] inputArray) { | |
var major = 0; | |
for (int i = 0; i < inputArray.Length; i++) { | |
var previous = i - 1; | |
var next = i + 1; | |
if (previous < 0 || next > inputArray.Length -1) continue; | |
var current = inputArray[i]; | |
var preval = inputArray[previous]; |
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
bool isIPv4Address(string inputString) { | |
var split = inputString.Split('.'); | |
if (split.Length != 4) return false; | |
for (int i = 0; i < 4; i++) { | |
var str = split[i]; | |
int intVal; | |
if (!int.TryParse(str, out intVal)) return false; | |
if (intVal < 0 || intVal > 255) return false; | |
} |
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
bool almostIncreasingSequence(int[] sequence) { | |
for (int i = 0; i < sequence.Length; i++) { | |
var items = createArray(i, sequence); | |
if (isIncreasingSequence(items)) return true; | |
} | |
return false; | |
} |
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
class ApiClient { | |
private string connectionString; | |
ctor(String connectionString) { | |
this.connectionString = connectionString; | |
} | |
public string FazAlgumaCoisa(string parametros) { | |
using (var conexao = new ConexaoComDb(connectionString)) { | |
return conexao.PegaDados(parametros); |
NewerOlder