Skip to content

Instantly share code, notes, and snippets.

View Cruel's full-sized avatar

Thomas Edvalson Cruel

View GitHub Profile
#!/usr/bin/env python
import os, socket, sys, struct, getopt
def sendfile(filename, ip):
statinfo = os.stat(filename)
with open(filename, 'rb') as f:
sock = socket.socket()
sock.connect((ip, 5000))
sock.send(struct.pack('!i', 1))
if struct.unpack("!b", sock.recv(1))[0] == 1:
@Cruel
Cruel / gist:c3960363681650d58fd7
Created January 7, 2016 07:50
3ds repo bot checklist
Sanity check:
- Validate the YAML
- Make sure required fields exist and are not empty:
- title
- dir
- author
- version
- description
- file
#include <cpp3ds/Window/EventManager.hpp>
#include <cpp3ds/Window/Keyboard.hpp>
#include <cpp3ds/System/Sleep.hpp>
#include <3ds.h>
#include <iostream>
namespace cpp3ds {
EventManager::EventManager() {
m_joystickThreshold = 10.f;
static int update_attrib_format(struct gl_vertex_array_object* vao)
{
int x, index = 0;
struct gl_vertex_attrib_array* attrib;
for (x = 0; x < VERT_ATTRIB_MAX; ++x) {
attrib = &vao->VertexAttrib[x];
if (attrib->Enabled) {
vao->AttributeFormats |= GPU_ATTRIBFMT(index, attrib->Size, attrib->Type);
// vao->AttributeFormats |= ((attrib->Size-1 << 2) | attrib->Type) << (index * 4);
vao->AttributePermutation |= index << (index * 4);
@Cruel
Cruel / gist:6399293
Created August 31, 2013 16:33
Find song by name name and artist name
$song = $this->Artist->Song->find('first', array(
'conditions' => array('Song.name'=>'Emotion'),
'contain' => array(
'Artist'=> array(
'conditions'=>array(
'Artist.name'=>'Daft Punk'
)
)
),
));
@Cruel
Cruel / gist:2833666
Created May 30, 2012 04:02
General purpose CakePHP URL slug routing
// app/Config/routes.php
Router::connect('/:controller/:id/:slug', array('action' => 'view'),
array(
'pass' => array('id', 'slug'),
'id' => '[0-9]+'
));