Skip to content

Instantly share code, notes, and snippets.

1000 iterations, 10000 samples
BitFields Style Pack: 00:00:00.0919455
BitFields Style Unpack: 00:00:00.3154235
BitConverter Pack: 00:00:00.0764927
BitConverter Unpack: 00:00:00.2149990
Direct Packing: 00:00:00.0325352
Direct Unpacking: 00:00:00.2034563
Direct Unpacking Unsafe:00:00:00.2150088
Access and Cast: 00:00:00.0308669
Access and Cast Back: 00:00:00.2004328
from kivy.app import App
from kivy.app import Builder
from kivy.uix.stacklayout import StackLayout
from kivy.uix.textinput import TextInput
Builder.load_string("""
<MyTextInput>:
size_hint: 1, None
font_size: 40
from kivy.app import App
from kivy.app import Builder
from kivy.uix.stacklayout import StackLayout
from kivy.uix.button import Button
Builder.load_string("""
#:set RED (1, 0, 0, 1)
#:set GREEN (0, 1, 0, 1)
#:set BLUE (0, 0, 1, 1)
@Alan-FGR
Alan-FGR / kv_eval_problem.py
Last active July 7, 2016 14:51
If you uncomment the code on line 15, it works properly
from kivy.app import App
from kivy.app import Builder
from kivy.uix.stacklayout import StackLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.properties import NumericProperty
Builder.load_string("""
(((1 << i) & checkMask) | ((1 << next) & checkMask)) != ((1 << i) | (1 << next))
((1 << i) & checkMask) != 0 && ((1 << next) & checkMask) == 0 || ((1 << i) & checkMask) == 0 && ((1 << next) & checkMask) != 0
@Alan-FGR
Alan-FGR / Quads.cs
Created November 9, 2016 18:12
Trying to render quads in Atomic
using System;
using AtomicEngine;
public class GameRoot : AppDelegate
{
private Texture2D sprite;
public override void Start()
{
var graphics = AtomicNET.GetSubsystem<Graphics>();
using System;
using AtomicEngine;
//################ Render.xml
//<renderpath>
// <command type="sendevent"/>
//</renderpath>
public class Program
{
@Alan-FGR
Alan-FGR / HelloAtomic.cs
Created November 10, 2016 12:10
Black Screen of Despair in Simple Atomic Example
using AtomicEngine;
public class GameRoot : AppDelegate
{
public override void Start()
{
// We will be needing to load resources.
// All the resources used in this example comes with Urho3D.
// If the engine can't find them, check the ResourcePrefixPath.
var cache = GetSubsystem<ResourceCache>();
@Alan-FGR
Alan-FGR / HelloQuadWithUI.cs
Created November 12, 2016 04:02
Rendering and UI in Atomic Engine
using AtomicEngine;
public class Program
{
public static void Main(string[] args)
{
Application.Run<HelloQuadWithUI>(args);
}
}
@Alan-FGR
Alan-FGR / plot.py
Created November 19, 2016 13:35
Totally Fine Readable Descriptive High-Quality Code
def plot(titl,xvals,yvals,xl,yl,pxw=720,pxh=450,dpi=80,xts=4,yts=1,inv=False):
from matplotlib import pyplot as plt; import matplotlib as mpl;
plt.style.use('seaborn-bright');
fig = plt.figure(figsize=(pxw/dpi, pxh/dpi), dpi=dpi, facecolor='w')
fig.subplots_adjust(left=.08, bottom=.1, right=.95, top=.92)
ax = fig.add_subplot(111); ax.minorticks_on()
ax.get_xaxis().set_minor_locator(mpl.ticker.AutoMinorLocator(xts))
ax.get_yaxis().set_minor_locator(mpl.ticker.AutoMinorLocator(yts))
ax.grid(b=True, which='minor',alpha=0.07,linestyle='-')
ax.grid(b=True, which='major',alpha=0.21,linestyle='-')