Skip to content

Instantly share code, notes, and snippets.

View graffic's full-sized avatar

Javier Gonel graffic

View GitHub Profile
@graffic
graffic / steam.md
Last active December 28, 2023 03:09
Downloading steam games from another computer/faster line

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
use std::rc::Rc;
use rusqlite::{params, Connection, Statement};
use owning_ref::OwningHandle;
struct MyStatements<'a> {
select_all: Statement<'a>,
select_one: Statement<'a>
}
type MyStatementsOwned = OwningHandle<Rc<Connection>, Box<MyStatements<'static>>>;
@graffic
graffic / stats.js
Last active October 7, 2021 08:38
Cookie clicker stats
// Calculates the price per click per second taking into account synergies.
function potato() {
const result = {}
for (const me of Object.values(Game.Objects).sort((a,b) => a.id - b.id)) {
let synergyBoost = 0
if (me.name=='Grandma')
{
for (var i in Game.GrandmaSynergies)
{
@graffic
graffic / test_something.py
Created April 26, 2019 07:34
Django tests show SQL queries
from django.test import TestCase
class TestSomething(TestCase):
def setUp(self):
from django.conf import settings
settings.DEBUG=True
def test_something(self):
pass
@graffic
graffic / mssql_slow_monitor.py
Last active August 19, 2019 12:04
El-cheapo mssql slow query monitor
#!/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 10:38
Failed attempt to register all DBSets
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 / Dockerfile
Created August 17, 2017 07:08
Alpine, java8, druid, mysql docker image
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 / fix_erlang.sh
Created June 23, 2018 09:15
Macports utils
#!/bin/bash
set -x
cd $MACPORTS/var/macports/sources/rsync.macports.org/release/tarballs/ports/
sed -i '' '/libGLU/d' ./lang/erlang/Portfile
portindex
// 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 / gist:6c15f8c2b4f0f208939e
Created May 11, 2014 19:49
Uncle bob "Framework Whipped" original post

Framework Whipped

Uncle Bob 11 May 2014 Craftsmanship Frameworks are powerful tools. We'd be lost without them. But there's a cost to using them.

The relationship between a programmer and a framework is similar to the relationship between an executive and an administrative assistant. The framework takes care of all the necessary details, so that the executive can focus on high level decisions.

Think of Rails, or Spring, or JSF, or Hibernate. Think about what writing a web system would be like without these frameworks to help you. The idea is disheartening. There'd be so many little piddling details to deal with. It'd be like endeavoring to construct a mnemonic memory circuit using stone knives and bearskins[1].

And so we gleefully use those glittering frameworks. We joyously intermingle our code with the frameworks' in anticipation of all the benefits they promise. We make the mistake that so many executives have made before us. We marry our secretary.