Skip to content

Instantly share code, notes, and snippets.

Avatar

Piero Dotti ProGM

View GitHub Profile
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active Nov 5, 2020
Arel cheatsheet on Steroids
View arel_cheatsheet_on_steroids.md

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

View BDD-steps.xml
<?xml version="1.0" encoding="UTF-8"?>
<document>
<steps>
<wait>5</wait>
<press>SkipIntro</press>
<wait>3</wait>
<press>Menu/Settings</press>
<wait>3</wait>
<press>SettingsTab/Options</press>
@ProGM
ProGM / diff_folders.sh
Created Mar 6, 2019
Check differences between two folders in bash
View diff_folders.sh
#!/usr/bin/env bash
tmpfile1=$(mktemp /tmp/report.XXXXXX)
tmpfile2=$(mktemp /tmp/report2.XXXXXX)
cd "$1"
find . >> $tmpfile1
cd "$2"
find . >> $tmpfile2
@ProGM
ProGM / delete_files_recursively.sh
Last active Mar 6, 2019
Delete files from a google drive folder via command line
View delete_files_recursively.sh
# Delete all files in the drive folder, excluding google docs
find . -type f \( ! -iname "*.gdoc" -and ! -iname "*.html" -and ! -iname "*.gsheet" -and ! -iname "*.gdraw" -and ! -iname "*.gslides" -and ! -iname "*.gform" -and ! -iname "*.gtable" -and ! -iname Icon\? \) -delete
@ProGM
ProGM / example.js
Last active Sep 3, 2017
Example indiexpo API implementation in Javascript
View example.js
/*
* An usage example of the previous library
*/
function loadData() {
// Send score 1
indiexpo.sendScore(1).then(function(data) {
console.log('score sent, response:', data);
});
// Get current user username
@ProGM
ProGM / main.rb
Last active Jun 19, 2017 — forked from coorasse/main.rb
CanCanCan Issue when compiling SQL using `accessible_by`
View main.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.1' # use correct rails version
@ProGM
ProGM / .bash_prompt
Created Feb 8, 2017
Customized dotfiles
View .bash_prompt
# Customized dotfiles. Original credits:
# Shell prompt based on the Solarized Dark theme.
# Screenshot: http://i.imgur.com/EkEtphC.png
# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles
# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
@ProGM
ProGM / CheckMissingReferencesInUnity.cs
Last active Nov 23, 2020
Finding Missing References in Unity 5.4+
View CheckMissingReferencesInUnity.cs
// Based on http://www.tallior.com/find-missing-references-unity/
// It fixes deprecations and checks for missing references every time a new scene is loaded
// Moreover, it inspects missing references in animators and animation frames
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using System.Linq;
[InitializeOnLoad]
View FloodFill.cs
using UnityEngine;
using System.Collections.Generic;
// Flood Fill implementation for Unity3D C#
// Used in: https://www.elfgamesworks.com/2016/12/14/identify-unwanted-maze-solutions-using-flood-fill-with-unity3d/
public static class ImageUtils
{
public struct Point {
@ProGM
ProGM / ExampleBehavior.cs
Created Oct 19, 2016
A PropertyDrawer to show a popup field with a generic list of string for your Unity3d attribute
View ExampleBehavior.cs
public class MyBehavior : MonoBehaviour {
// This will store the string value
[StringInList("Cat", "Dog")] public string Animal;
// This will store the index of the array value
[StringInList("John", "Jack", "Jim")] public int PersonID;
// Showing a list of loaded scenes
[StringInList(typeof(PropertyDrawersHelper), "AllSceneNames")] public string SceneName;
}
You can’t perform that action at this time.