Skip to content

Instantly share code, notes, and snippets.

View derlin's full-sized avatar

Lucy Linder derlin

View GitHub Profile

Barcode checker

A little PYTHON code for basic barcode checking before using an ESC/POS printer barcode renderig function. This ensures the barcode will be renderer correctly.

Note that most ESC/POS printers, such as the Epson TM T20ii, don't usually bother with the checksums and stuff; they only care about the character set and the length of the string. There are also some special formats, for example the CODE128 should be prefixed with {B for alphanumeric barcodes, etc.

@derlin
derlin / A list of country codes TLDS.md
Last active April 6, 2025 12:12
List of Country Code TLDs in CSV and JSON

This list has been extracted from https://www.worldstandards.eu/other/tlds/.

For JSON format, copy-paste the following in the developer console (Chrome):

results=[]; jQuery('table tr').each(function(){
  tds = jQuery.map(
    jQuery(this).find('td'), 
    (elt) => jQuery(elt).text()
 );
@derlin
derlin / ExtractTextAndLinksExample.java
Last active December 22, 2019 07:56
Scraping HTML: Apache Tika + Boilerpipe to extract sentences and links from webpages.
import org.apache.tika.exception.TikaException;
import org.apache.tika.sax.Link;
import org.xml.sax.SAXException;
import java.io.IOException;
public class ExtractTextAndLinksExample {
static final String url = "http://www.flagsarenotlanguages.com/blog/why-flags-do-not-represent-language/";
@derlin
derlin / keybase.md
Last active November 16, 2019 14:12

Keybase proof

I hereby claim:

  • I am derlin on github.
  • I am derlin (https://keybase.io/derlin) on keybase.
  • I have a public key ASDCDwOI9YfPG2NimmsisdRQS7yKNXkl35j-hcXNVCv4nQo

To claim this, I am signing this object:

# left and right click reversed, scroll with small right button, middle click with small right button, go back with small left button
# xinput buttons: left-click middle-click right-click wheel-up wheel-down -wheel-left wheel-right thumb1 thumb-2 extbt7 extbt8
xinput set-button-map "Logitech USB Trackball" 3 9 1 4 5 6 7 8 2 # left-handed
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Button" 8 8
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation" 8 1
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Axes" 8 6 7 4 5
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation X Axis" 8 6
xinput set-int-prop "Logitech USB Trackball" "Evdev Drag Lock Buttons" 8 9
@derlin
derlin / RigidBodyController.cs
Created April 26, 2017 06:52
Script to control a rigidbody character. It is adapted from http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker Main changes: - add animator (should have at least two parameters: `Forward` and `Jump` - make the body rotate in the direction of the movement
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(CapsuleCollider))]
// taken and adapted from http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker
public class RigidBodyControllerSimple : MonoBehaviour
{
public float speed = 10.0f;
@derlin
derlin / PlayerPrefsX.cs
Created April 26, 2017 06:52
Scores management
// ArrayPrefs2 v 1.4
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class PlayerPrefsX
{
static private int endianDiff1;
@derlin
derlin / ScoresTable.cs
Created April 26, 2017 06:50
Score display
using UnityEngine;
using UnityEngine.UI;
public class ScoresTable : MonoBehaviour
{
public GameObject cellPrefab;
public GameObject noScore;
public GameObject headers;
@derlin
derlin / Platform.md
Created April 26, 2017 06:49
Unstable platform with a pivot

Structure:

GameObject: 
  * RigidBody: play with the mass and the angular drag to parameterize the platform
↳ Pivot - Square: the pivot
  * RigidBody
  * Fixed Joint with break force and break torque set to Infinity, body to None and preprocessing ticked

↳ Plateau - Circle|.. : the actual plateau

@derlin
derlin / HealthLevelAbovePlayer.cs
Created April 26, 2017 06:48
Display a health bar above the player in 3D
using UnityEngine;
using UnityEngine.UI;
public class HealthLevelAbovePlayer : MonoBehaviour
{
private Image[] images;
private RectTransform levelRectTransform;
private RectTransform containerRectTransform;
private float displayFactor;