Skip to content

Instantly share code, notes, and snippets.

View yorikvanhavre's full-sized avatar

Yorik van Havre yorikvanhavre

View GitHub Profile
@yorikvanhavre
yorikvanhavre / py2to3-test.diff
Created April 10, 2013 23:40
a first test to convert a module from py2 to py3, contains a couple of solutions
diff --git a/src/3rdParty/Pivy-0.5/coin_wrap.cpp b/src/3rdParty/Pivy-0.5/coin_wrap.cpp
index ee304d6..fe1c8d7 100644
--- a/src/3rdParty/Pivy-0.5/coin_wrap.cpp
+++ b/src/3rdParty/Pivy-0.5/coin_wrap.cpp
@@ -1,3 +1,4 @@
+
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.36
@@ -880,7 +881,11 @@ SWIG_Python_AddErrorMsg(const char* mesg)
@yorikvanhavre
yorikvanhavre / ace_editor_threejs.html
Created April 12, 2013 03:34
Dan Falck showed me this
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
#b3 {
position: absolute;
top: 5%;
right: 0;
@yorikvanhavre
yorikvanhavre / info object
Last active December 16, 2015 17:09
very simple info-carrying object
# custom object definition
class MyCustomObject():
def __init__(self,obj):
obj.addProperty("App::PropertyStringList","CustomProps","Base", "A placeholder for custom properties")
obj.Proxy = self
def execute(self,obj):
pass
# create one in the current doc
myobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","MyObject")
@yorikvanhavre
yorikvanhavre / pivy-texture-scaling
Created July 8, 2013 22:41
How to scale a texture with pivy. Last method (using a SoTextureCoordinatePlane) allows to give a scale independently of the size of the object
Python 2.7.5+ (default, Jun 2 2013, 13:28:26)
[GCC 4.7.3] on linux2
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> App.setActiveDocument("Unnamed")
>>> App.ActiveDocument=App.getDocument("Unnamed")
>>> Gui.ActiveDocument=Gui.getDocument("Unnamed")
>>> import Draft
>>> pl = FreeCAD.Placement()
>>> pl.Rotation.Q = (0.0,-0.0,-0.0,1.0)
>>> pl.Base = FreeCAD.Vector(-1.33731794357,0.644989609718,0.0)
#***************************************************************************
#* *
#* Copyright (c) 2013 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
@yorikvanhavre
yorikvanhavre / html-thumbnailer
Created August 17, 2013 01:58
html thumbnailer
cutycapt --url=file:///home/yorik/Site/index.html --out=/tmp/tmpthumb.jpg && convert /tmp/tmpthumb.jpg -thumbnail 150x180^ -gravity NorthWest -extent 150x180 thumb.jpg
def normalizeAngle(angle,amin=-180,amax=180):
"normalizes the given angle"
if angle > amax:
return normalizeAngle(angle-amax)
elif angle < amin:
return normalizeAngle(angle+amin)
else:
return angle
@yorikvanhavre
yorikvanhavre / FeedController.class.php.diff
Created August 10, 2014 22:31
ProjectPier : export tasks to google calendar - application/controllers/FeedController.class.php
187,189d186
< $todo = new iCalendar_Todo();
< $todo->setPropertyValue('SUMMARY', $project->getName().": ".$task->getText());
< $todo->setPropertyValue('UID', 'a9idfv00fd99q344o' . rand() . 'cgef733m6bs@google.com');
190a188,191
> $lines = explode("\n",$task->getText());
> $title = $lines[0];
> $title = preg_replace( "/\r|\n/", "", $title );
> $text = preg_replace( "/\r|\n/", " ", $task->getText() );
191a193,195
@yorikvanhavre
yorikvanhavre / contacts_sidebar.php.diff
Created August 11, 2014 02:12
ProjectPier: add a link in the contacts view's sidebar - application/views/dashboard/conotacts_sidebar.php
16a17,19
> <div class="contactExport">
> <a href="application/views/dashboard/export_vcf.php"><?php echo lang('export vcard file');?></a>
> </div>
@yorikvanhavre
yorikvanhavre / export_vcf.php
Last active August 29, 2015 14:05
ProjectPier: export the contacts list as VCard - application/views/dashboard/export_vcf.php
<?php
require('../../../config/config.php');
date_default_timezone_set("America/Sao_Paulo");
header('Content-Type: text/vcard; charset=utf-8'); //To tell that the data is a visiting card format
header('Content-Disposition: attachment; filename=projectpier_contacts.vcf'); //To make the data downloadable
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(DB_NAME,$conn)or die(mysql_error());
$companies = array();
$comp = mysql_query('SELECT name,id FROM `'.DB_PREFIX.'companies`');