Skip to content

Instantly share code, notes, and snippets.

@dcloud
dcloud / ImageLoader.as
Created October 25, 2010 20:58
Example of using Loader class to load images, plus some stuff on tracing items in a DisplayObjectContainer's display list.
package {
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.*;
public class ImageLoader extends Sprite
{
private var _ldr:Loader;
private var _urlReq:URLRequest;
@dcloud
dcloud / xcode-git-version.sh
Created February 6, 2013 22:08
My simple version of using git commit count to set build numbers in Xcode.
#!/bin/sh
#
git=`sh /etc/profile; which git`
count=`$git rev-list --all | wc -l`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $count" "${PROJECT_DIR}/${INFOPLIST_FILE}"
@dcloud
dcloud / mapbox_autolayout_upgrade
Created January 28, 2014 18:14
mapbox upgrade creates autolayout issue
0xcc7ab20 V:[UIImageView:0xe1d0b00]-(3)-[_UILayoutGuide:0xcc9a270]>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
2014-01-28 13:09:02.400 Congress[15314:70b] View hierarchy unprepared for constraint.
Constraint: <NSLayoutConstraint:0xcc7ab20 V:[UIImageView:0xe1d0b00]-(3)-[_UILayoutGuide:0xcc9a270]>
Container hierarchy:
MapView at {0,0}-{320x548}
| <RMLoadingTileView: 0xe1ccec0; baseClass = UIScrollView; frame = (0 0; 320 548); clipsToBounds = YES; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0xe1cd380>; layer = <CALayer: 0xe1cd100>; contentOffset: {320, 548}>
| | <UIView: 0xe1cd550; frame = (0 0; 960 1644); layer = <CALayer: 0xe1cd5b0>>
| <RMMapScrollView: 0xcf51b90; baseClass = UIScrollView; frame = (0 0; 320 548); opaque = NO; gestureRecognizers = <NSArray: 0xcf4e
@dcloud
dcloud / 990-p2.html
Created February 23, 2014 15:52
hOCR output for a single page using tesseract on images extracted from pdfs using poppler
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='ocr-system' content='tesseract 3.02.02' />
<meta name='ocr-capabilities' content='ocr_page ocr_carea ocr_par ocr_line ocrx_word'/>
</head>
@dcloud
dcloud / elec_shopping_ch1.markdown
Last active August 14, 2023 14:29
Make Electronics Shopping List

Chapter 1 Parts List

Tools

###Small pliers

RadioShack 4.5-inch mini long-nose pliers, part number 64-0062, or Xcelite 4-inch mini long-nose pliers, model L4G. Or similar. The brand is unimportant. After you use them for a while, you'll develop your own preferences. In particular, you have to decide whether you like spring-loaded handles. If you decide you don't, you'll need a second pair of pliers to pull the springs out of the first.

I have small pliers, probably okay.

@dcloud
dcloud / segment2segment_distance.py
Created July 30, 2014 15:25
Line segment distance algorithm
import numpy as np
def segment2segment_distance(a, b):
"""
Adapted from http://geomalgorithms.com/a07-_distance.html
"""
SMALL_NUM = 0.00000001
S1P0 = np.array(a[:2])
S1P1 = np.array(a[2:])
S2P0 = np.array(b[:2])
@dcloud
dcloud / unicode_reg
Last active September 4, 2020 17:55
That is so cool
# Curly/Educated marks are \u2018-\u201F in Unicode
# python
re.findall(u'[\u2018-\u201F]', apage)
# bash
for i in $(seq 0x2018 0x201F); do
echo "char: \u$(( [##16]i ))"
done
@dcloud
dcloud / interactive_list.md
Last active January 12, 2016 02:51
News Interactives worth sharing
@dcloud
dcloud / merge_ogr.py
Created March 31, 2016 22:16
Quick and dirty KML to shape file conversion, with problems :(
import os
import ogr
import osr
import argparse
fileEndsWith = '.shp'
driverName = 'ESRI Shapefile'
def main():

Keybase proof

I hereby claim:

  • I am dcloud on github.
  • I am danielcloud (https://keybase.io/danielcloud) on keybase.
  • I have a public key ASC9bcnHkszqGuxzDy5VZUhwe8Bu8eTzAGAvVyeAOvrqJAo

To claim this, I am signing this object: