Skip to content

Instantly share code, notes, and snippets.

View bianchimro's full-sized avatar
🤡

Mauro Bianchi bianchimro

🤡
View GitHub Profile
@bblanchon
bblanchon / example.py
Created April 9, 2021 09:03
Django Subquery Aggregate (Count, Sum...)
from django.db.models import OuterRef
weapons = Weapon.objects.filter(unit__player_id=OuterRef('id'))
units = Unit.objects.filter(player_id=OuterRef('id'))
qs = Player.objects.annotate(weapon_count=SubqueryCount(weapons),
rarity_sum=SubquerySum(units, 'rarity'))
@dalezak
dalezak / README.md
Last active September 11, 2023 09:51
Ionic Capacitor Resources Generator
  1. Run npm install cordova-res --save-dev
  2. Create 1024x1024px icon at resources/icon.png
  3. Create 2732x2732px splash at resources/splash.png
  4. Add "resources": "cordova-res ios && cordova-res android && node scripts/resources.js" to scripts in package.json
  5. Copy resources.js file to scripts/resources.js
  6. Run sudo chmod -R 777 scripts/resources.js
  7. Run npm run resources

======================== DEP XXX: Simplified routing syntax

  • DEP: XXX
  • Author: Tom Christie
  • Implementation Team: Tom Christie
  • Shepherd: Tim Graham
  • Status: Draft
  • Type: Enhancement
@iammerrick
iammerrick / PinchZoomPan.js
Last active April 22, 2024 02:54
React Pinch + Zoom + Pan
import React from 'react';
const MIN_SCALE = 1;
const MAX_SCALE = 4;
const SETTLE_RANGE = 0.001;
const ADDITIONAL_LIMIT = 0.2;
const DOUBLE_TAP_THRESHOLD = 300;
const ANIMATION_SPEED = 0.04;
const RESET_ANIMATION_SPEED = 0.08;
const INITIAL_X = 0;
@PsychicCat
PsychicCat / test.js
Last active January 26, 2018 17:56
Retrieve a standard Monero Payment ID from a transaction in the mempool
// execute a GET to your Monero daemon at /get_transaction_pool
daemon.getTransactionPool().then(function(result) {
if(result.status == 'OK' && result.transactions){
let transactions = result.transactions;
// iterate through the transactions and check to see if it contains a payment ID
transactions.forEach(function(transaction) {
let tx = JSON.parse(transaction.tx_json);
let extra = parseExtra(tx.extra);
@ghinda
ghinda / git-commit-csv-export.sh
Last active May 6, 2024 07:07
git csv export of commits in the last month
git log --since='last month' --pretty=format:'%h;%an;%ad;%s' --author='Ionut Colceriu' > ~/log.csv
@JulienBlancher
JulienBlancher / filter.d_nginx-auth.conf
Last active March 26, 2024 12:52
Fail2ban Config with Nginx and SSH
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =
@nolanlawson
nolanlawson / _blob-shim.md
Last active February 20, 2017 17:34
HTML5 Blob shim

HTML5 Blob shim

Small JavaScript function that abstracts constructing a Blob object, so it works in older browsers that don't support the native Blob constructor (e.g. old versions of QtWebKit).

Usage

The function createBlob() simply replaces new Blob():

@fredj
fredj / index.html
Created March 31, 2014 15:13
ol3 particles
<!doctype html>
<html lang="en">
<head>
<title>ol3 particles</title>
<style>
html, body, .map {
margin: 0;
padding: 0;
width: 100%;
@johannes-weber
johannes-weber / ValidateFloat.js
Last active January 24, 2016 10:35
AngularJS Custom Float Validation
'use strict';
/**
* This directive parses both 1.2 and 1,2 into a valid float number 1.2.
* Note that you can't use input type number here as HTML5 browsers would
* not allow the user to type what it would consider an invalid number such as 1,2.
*
* <input ng-model="{yourModel}" validate-float />
*/
angular.module('Library').directive('validateFloat', function () {