Skip to content

Instantly share code, notes, and snippets.

View Sacristan's full-sized avatar

Ģirts Ķesteris Sacristan

View GitHub Profile
@henrik
henrik / nullify_blank_attributes.rb
Created November 27, 2010 10:11
ActiveRecord mixin to save NULL instead of empty strings to database.
module NullifyBlankAttributes
def write_attribute(attr_name, value)
new_value = value.presence
super(attr_name, new_value)
end
end
@joelverhagen
joelverhagen / README.md
Created February 12, 2012 02:14
Jekyll YouTube Embed Plugin

This is a plugin meant for Jekyll.

Example use:

Easily embed a YouTube video. Just drop this file in your _plugins directory.

{% youtube oHg5SJYRHA0 %}
@equivalent
equivalent / README.md
Last active December 16, 2021 16:34
String "false" to_bool ... or how to convert Rails/SimpleForm radio buttons to boolean

This gist was writen in 2012 and it was solving specific problem in Rails & SimpleForm. Some fellow developers were pointing out this may be out dated concept. That's why I advise everyone to read comment section bellow to have a full grasp of alternative solutions

other sources that may be helpful to understand why this may not be best idea:

@jwo
jwo / mysql.database.yml
Last active March 28, 2024 15:32
Sample config/database.yml from Rails. Postgres, MySQL, and SQLite
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
@aras-p
aras-p / file.md
Last active September 30, 2016 08:29
"Unity on mobile wtfs"

Too long to reply on twitter, so.

300 vertex limit[900 = uv+norm+pos), 6 passes for dynamic shadows, terrain shader is inefficient, etc... Win RT+Unity sounds FUN!

I haven't watched the video, but have looked at the slides. So, point by point:

300 vertex limit

That is for dynamic batching, i.e. meshes larger than that aren't transformed on the CPU each frame to try to save the draw calls. This isn't a WinRT limiation; it simply doesn't make sense to spend CPU time transforming larger meshes, in order to save some CPU time to save a draw call.

@wrh
wrh / ObjectPool.cs
Created November 6, 2013 19:13
Three kinds of generic object pools to avoid memory deallocations in Unity-based games. Released under a Creative Commons Attribution (CC BY) License, see http://creativecommons.org/licenses/ (c) 2013 Wendelin Reich.
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
////
//// Three kinds of generic object pools to avoid memory deallocations
//// in Unity-based games. See my Gamasutra articles.
//// Released under a Creative Commons Attribution (CC BY) License,
//// see http://creativecommons.org/licenses/
////
//// (c) 2013 Wendelin Reich.
////
@juderosen
juderosen / git-wars.md
Last active April 25, 2024 15:16
Git Wars: GitHub vs Bitbucket

Git Wars: GitHub vs Bitbucket

Introduction

Now, you might think the answer I'm going to give you is already obvious because I'm using GiHub right now, but it's not. Both GitHub and Bitbucket offer great Git services, but each has its own features and pricing plans. In the following... thing, I'm going to compare the two and then offer a final solution that should work for most people.

TL;DR: Both. Use GitHub for open source and public repos (you'll spend most of your time here) and Bitbucket for private repos. But, sign up for GitHub first, then import account into Bitbucket. Also, check comments for updates. P.S. I personally prefer GitHub.

Interface and Functionality

@benblo
benblo / EditorCoroutine.cs
Created April 15, 2014 13:26
EditorCoroutine: coroutines for Unity editor operations. Usage: EditorCoroutine.start(myIEnumerator)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Swing.Editor
{
public class EditorCoroutine
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 2, 2024 09:31
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@JakubNei
JakubNei / Occlusion.Area.cs
Last active September 25, 2020 15:34
Lame Implementation of Area and Portal Occlusion Culling based on DOOM 3 BFG http://www.iddevnet.com/doom3/visportals.php https://github.com/id-Software/DOOM-3-BFG
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Extensions;
namespace Occlusion
{
public class Area : MonoBehaviour
{