Skip to content

Instantly share code, notes, and snippets.

@ProGM
ProGM / main.rb
Last active June 19, 2017 10:09 — forked from coorasse/main.rb
CanCanCan Issue when compiling SQL using `accessible_by`
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 February 8, 2017 18:31
Customized dotfiles
# 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 July 18, 2023 14:22
Finding Missing References in Unity 5.4+
// 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]
@ProGM
ProGM / FloodFill.cs
Last active December 29, 2022 03:13
A simple Flood Fill implementation for Unity3D C# for video games. https://elfgames.com/2016/12/14/identify-unwanted-maze-solutions-using-flood-fill-with-unity3d/
// Copyright (c) 2022 Piero Dotti, Elf Games
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
@ProGM
ProGM / ExampleBehavior.cs
Created October 19, 2016 10:39
A PropertyDrawer to show a popup field with a generic list of string for your Unity3d attribute
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;
}
@ProGM
ProGM / debug.rb
Created October 12, 2016 10:36
Debugging neo4j.rb
Neo4j::ActiveBase.current_session.adaptor.logger.level = Logger::DEBUG
Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query(&method(:puts))
Neo4j::Core::CypherSession::Adaptors::HTTP.subscribe_to_request(&method(:puts))
Neo4j::Core::CypherSession::Adaptors::Embedded.subscribe_to_transaction(&method(:puts))
@ProGM
ProGM / DraggablePoint.cs
Last active April 25, 2023 07:45
A Unity Editor extension to generate draggable points for vector3 serialized attributes.
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class DraggablePoint : PropertyAttribute {}
#if UNITY_EDITOR
@ProGM
ProGM / cursed_query.rb
Created September 16, 2016 15:55
Neo4jrb 8.0 breaking query with bolt
# Running this query in neo4j 8.0 using bolt, breaks the current session:
Neo4j::ActiveBase.current_session.query("CREATE (n:`Version`:`Quotable`) SET n = {props} RETURN n", {:props=>{:uuid=>"547240ab-50ef-4c3a-9a39-056c697498d0", :created_at=>1474040467, :updated_at=>1474040467, :title=>"Indus OS Raises $5M To Make Android Work For First-Time Smartphone Users In India", :abstract=>"If you want proof that Android is the operating system of emerging markets, look no further than Indus OS. The company, formerly known as Firstouch, is tweaking the Google-run operating system to the unique demands and culture of India. And it's raised $5 million in fresh funding to push on with its lofty target of reaching one billion emerging market users.", :content=>"\n<p data-uuid=\"9a7cd60f-e203-4ed9-a0f3-5538701bcd6c\"><img src=\"https://tctechcrunch2011.files.wordpress.com/2016/01/india-phone.jpg?w=738\"></p><p data-uuid=\"58ada0fb-c007-4714-b5bf-2422f542ae9f\">If you want proof that Android is the operating system of emer
@ProGM
ProGM / prepare_images_for_appcelerator.sh
Created August 25, 2016 13:49
Prepare and resize images for Appcelerator using imagemagick
#!/usr/bin/env bash
origin_raw_folder="raw_images"
rm -rf images
mkdir -p images/iphone
mkdir -p images/android/res-hdpi
mkdir -p images/android/res-hdpi
mkdir -p images/android/res-xhdpi
mkdir -p images/android/res-xxhdpi
class Tree
attr_reader :data
def initialize(data)
@data = data
end
def +(other)
Tree.new(deep_merge(@data, other.is_a?(Tree) ? other.data : other))
end