Skip to content

Instantly share code, notes, and snippets.

@SabinT
SabinT / blender-get-selected-vertex.py
Last active August 29, 2015 14:20
Get selected vertex in blender
def selected_vertex():
for vert in bpy.context.selected_objects[0].data.vertices:
if vert.select:
return vert;
return None
@avshabanov
avshabanov / InvokeInterfaceCost.java
Created May 5, 2015 05:44
InvokeInterface: Java vs C
/**
* @author Alexander Shabanov
*/
public class InvokeInterfaceCost {
public interface Modify {
int apply(int value);
}
public static final class DecOne implements Modify {
@efleming969
efleming969 / example.java
Created April 15, 2015 05:16
SOLID: Liskov Substitution
class Liskov {
public static int calculateArea(Rectangle x) {
return x.getHeight() * x.getWidth();
}
public static int calculateArea(Square x) {
return x.getHeight() * x.getHeight();
}
}
@m0tive
m0tive / gist:37e8ec0aae962af359f7
Created April 10, 2015 11:56
array and hash for lua
-- I haven't tested these, they probably don't work
local object = {
type = function(self) return getmetatable(self).__index end,
}
local hash = {
data = function(self) return getmetatable(self).data end,
set = function(self, key, value) rawset(self.data, key, value) end,
anonymous
anonymous / file1.py
Created February 9, 2015 05:43
Pasted from IPython
sum=0
for i in range(1,1000):
if i%3==0 or i%5==0:
sum += i
print sum
@yutopio
yutopio / Aes.cs
Last active August 29, 2015 14:14
AES Cryptography Sample
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main(string[] args)
{
string iv, key;
@buren
buren / rails_web_console_param.rb
Last active February 13, 2016 18:16
Attach a rails web console to any page by adding ?web_console=
# config/initializers/web_console.rb
WebConsoleBeforeAction = ->(controller) do
controller.console if controller.params[:web_console]
end
ApplicationController.before_action(WebConsoleBeforeAction) if defined?(WebConsole) && Rails.env.development?
# NOTE:
# For security reasons only do this in development.
@WanghongLin
WanghongLin / color.sh
Created December 26, 2014 06:28
A simple shell script to output an ANSI terminal color chart
#!/bin/sh
#
# colors v1.03
#
# A simple shell script to output an ANSI terminal color chart.
# It may be useful when trying to customize your ANSI terminal
# color scheme!
#
# Written and placed in the public domain by Ian Abbott <ian@abbott.org>
#
/*
Amazing algorithm:-
inorder traversal without using stacks and recursion just by manipulating threads between them.
http://www.geeksforgeeks.org/inorder-tree-traversal-without-recursion-and-without-stack/
*/
void inorder_morris(node *root){
if(root == NULL) return ;
node *cur, *pre;
cur = root;
@valleyapps
valleyapps / arduino.ino
Last active August 29, 2015 14:12 — forked from glisha/arduino.ino
boolean wifiReady = 0;
boolean wifiConnected = 0;
void setup() {
pinMode(10,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(10,LOW);
digitalWrite(13,LOW);
Serial.begin(115200);