Skip to content

Instantly share code, notes, and snippets.

View demian85's full-sized avatar
🏠
Hacking from home

Demián Rodriguez demian85

🏠
Hacking from home
View GitHub Profile
@demian85
demian85 / agg.js
Created February 11, 2021 14:40
mongodb insane aggregation query
.aggregate([
{
$lookup: {
from: 'snapshots',
let: { address: '$address' },
pipeline: [
{
$match: {
$expr: {
$and: [
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const mode = process.env.NODE_ENV || 'production';
const devtool = mode === 'development' ? 'cheap-module-source-map' : 'source-map';
const serverBuild = {
mode,
// ==UserScript==
// @name Colorful Teg
// @version 1.0
// @match *teg.avature.net*
// @run-at document-end
// ==/UserScript==
[
'.analysis_functional > td {background-color: rgba(255, 80, 168, 0.45) !important; }',
'.testing > td { background-color: rgba(255, 255, 176, 0.45) !important; }',
@demian85
demian85 / sucks.php
Created October 18, 2012 14:18
handlebars.js con PHP...
<?
$db = DB::getConnection();
$sql = "SELECT * FROM Projects ORDER BY name";
$data = $db->query($sql)->fetchAll();
array_walk($data, function(&$v) {
$v['enabled'] = (int)$v['enabled'];
$v['visible'] = (int)$v['visible'];
});
Response::json($data);
?>
@demian85
demian85 / numberFormat.js
Created July 12, 2012 16:06
JS number format func
function numberFormat(number, dec, dsep, tsep) {
if (isNaN(number)) return "";
number = number.toFixed(dec || 0);
var pindex = number.indexOf('.'), fnums, decimals, parts = [];
if (pindex > -1) {
fnums = number.substring(0, pindex).split('');
decimals = (dsep || '.') + number.substr(pindex+1);
}
else {
fnums = number.split('');
/**
* Create HTML anchor tags replacing URL's
*
* @param string $input
* @param string $target anchor target attribute
* @return string
*/
function parseLinks($input, $target = '_blank') {
return preg_replace('#(^|\s)((?:http|https|ftp)://.+?\.[a-z]{2,3}.*?)(\s|$)#i', '$1<a href="$2" target="' . $target . '">$2</a>$3', $input);
}
@demian85
demian85 / magic.js
Created August 31, 2011 17:51
node http proxy
var httpProxy = require('http-proxy'),
http = require('http');
var options = {
router: {
'.*?\.demian.magic.com': '127.0.0.1:8000'
}
};
var proxyServer = httpProxy.createServer(options);
proxyServer.listen(80);
@demian85
demian85 / gist:1135081
Created August 9, 2011 20:16
GDD2011 test #3
var util = require('util'),
fs = require('fs');
// textos...
var txta = fs.readFileSync('a.txt', 'utf8');
var txtb = fs.readFileSync('b.txt', 'utf8');
var words = txtb.trim().split(/\s+/);
var uniq = [];
words.forEach(function(w) {
var util = require('util'),
http = require('http'),
connect = require('connect'),
express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
@demian85
demian85 / gist:991389
Created May 25, 2011 17:10
request timeout test
process.env.TZ = 'UTC';
var util = require('util'),
fs = require('fs'),
request = require('request'),
args = require('argsparser').parse();
for (var count = 0; count < 10; count++) {
(function(i) {
var uri = 'http://www.google.com/?i=' + i;