Skip to content

Instantly share code, notes, and snippets.

Javier Gonel graffic

Block or report user

Report or block graffic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@graffic
graffic / mssql_slow_monitor.py
Last active Aug 19, 2019
El-cheapo mssql slow query monitor
View mssql_slow_monitor.py
#!/usr/bin/env python
from datetime import datetime
from functools import wraps
from hashlib import sha1
from time import sleep
import os
import pymssql
import click
from sty import fg, rs
@graffic
graffic / AutofacModule.cs
Created May 24, 2019
Failed attempt to register all DBSets
View AutofacModule.cs
public class AutofacModule:Module
{
private static readonly object[] NoParameters = new object[] { };
protected override void Load(ContainerBuilder builder)
{
var dbsetType = typeof(DbSet<>);
var registerMethod = new Func<ContainerBuilder, Func<IComponentContext, object>, IRegistrationBuilder<object, SimpleActivatorData, SingleRegistrationStyle>>(Af.RegistrationExtensions.Register<object>)
.Method.GetGenericMethodDefinition();
foreach (var property in typeof(ApplicationDbContext).GetProperties())
@graffic
graffic / test_something.py
Created Apr 26, 2019
Django tests show SQL queries
View test_something.py
from django.test import TestCase
class TestSomething(TestCase):
def setUp(self):
from django.conf import settings
settings.DEBUG=True
def test_something(self):
pass
View fix_erlang.sh
#!/bin/bash
set -x
cd $MACPORTS/var/macports/sources/rsync.macports.org/release/tarballs/ports/
sed -i '' '/libGLU/d' ./lang/erlang/Portfile
portindex
View purchaseHistory.js
// Run in console or as a snippet in Chrome
(function() {
const parseUs = x => parseFloat(x.replace(",",""));
const parseEu = x => parseFloat(x.replace(/[,.]/g, y => y == "," ? "." : ","))
const parsers = new Map([
[",", parseEu],
[".", parseUs]
]);
const matcher = /^([^\d]?)([\d\,\.]+\d\d)([^\n\d]?)(\nCredit|)/m;
const matchNode = x => matcher.exec(x.innerText);
@graffic
graffic / 0.10.1_full_services_pom.xml
Last active Dec 9, 2017
Druid 0.11 & 0.10.1 poms to compile with CDH 5.10.2
View 0.10.1_full_services_pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Druid - a distributed column store.
~ Copyright 2012 - 2015 Metamarkets Group Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
@graffic
graffic / steam.md
Last active Sep 27, 2019
Downloading steam games from another computer/faster line
View steam.md

Framing the issue

With almost no bandwith at home, I needed a way to download DOOM that didn't involve blocking the home internet line for two days.

Approach

Using steamcmd you can use any computer to download steam games.

Downloading

  1. Install it
  2. Open it and loging with your username and password: login username password
@graffic
graffic / Dockerfile
Created Aug 17, 2017
Alpine, java8, druid, mysql docker image
View Dockerfile
FROM anapsix/alpine-java:8_server-jre
ENV DRUID_VERSION=0.10.0 \
ZOOKEEPER_VERSION=3.4.10 \
PATH=/usr/local/bin:${PATH}
# Prepare the container to install the software
RUN set -ex && \
apk upgrade --update && \
apk add --update curl mariadb mariadb-client supervisor && \
@graffic
graffic / maze.py
Created Jan 27, 2017
bkkhack tournament
View maze.py
maze = """XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX.XXXXX XXXXX XXXXXXXXXXX
XXX XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX
XXX XX XXXXXXXX XXX XXXX XXXXX XXXX
XXX XX XXXXXXXXXXXXXX XXXXXXXX XXX XXXX XXXXX XXXX
XXX XX XXXXXXXXXXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXX XXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXX XXXXXX XX X XXX XXXXXXXXXX XXXXX XXXX
XXX XX XXX XXXXXX XX X XXX XXXXX XXXXX XXXX
@graffic
graffic / async.py
Created Sep 9, 2015
Async demo python 3.5
View async.py
import aiohttp
import asyncio
async def get(index):
response = await aiohttp.get('http://httpbin.org/delay/%d' % index)
print(index, "Done")
response.close()
async def doMany():
coros = []
You can’t perform that action at this time.