Skip to content

Instantly share code, notes, and snippets.

@thieso2
thieso2 / CMTimeFlags+description.swift
Created November 17, 2020 08:47
CMTimeFlags.description
import CoreMediaIO
extension CMTimeFlags: CustomStringConvertible {
public var description: String {
let flags : [(CMTimeFlags, String)] = [
(.valid, "valid"),
(.hasBeenRounded, "hasBeenRounded"),
(.positiveInfinity, "positiveInfinity"),
(.negativeInfinity, "negativeInfinity"),
(.indefinite, "indefinite"),
@thieso2
thieso2 / CryptoKit.swift
Created September 10, 2020 09:43
encrypt and decrypt CryptoKit
import CryptoKit
import Foundation
// https://stackoverflow.com/questions/56828125/how-do-i-access-the-underlying-key-of-a-symmetrickey-in-cryptokit
extension SymmetricKey {
init(base64Encoded: String) {
self.init(data: Data(base64Encoded: base64Encoded)!)
}
var base64Encoded: String {
@thieso2
thieso2 / docker
Last active December 20, 2015 16:49
some docker stuff
# remove all images
$ docker rmi `docker images |sort -r| grep -v "^REPOSITORY" | awk '{print $3}'`
# remove all containers
$ docker rm `docker ps -a | awk '{print $1}'`
# min ubuntu image
$ mkdir /home/vagrant/new
$ debootstrap --variant=minbase --arch=amd64 precise /home/vagrant/new http://192.168.1.50:3142/ubuntu
$ cd /home/vagrant/new
$ tar cvfz ../min.tgz .
test 'gets index as json' do
user1 = user2 = nil
without_access_control do
User.destroy_all
user1 = FactoryGirl.create(:user, role: "user")
user2 = FactoryGirl.create(:user, role: "admin")
end
<?php
function calculate_total($haehnchen_preis, $haehnchen_anzahl) {
$mein_profit = 100;
return $haehnchen_preis * $haehnchen_anzahl + $mein_profit;
}
?>
@thieso2
thieso2 / plat_forms_2011 rake stats
Created January 20, 2011 13:47
rake stats fop tmp8's Plat_Forms Submission 2011 (http://www.plat-forms.org/platforms-2011)
(in /Users/thieso/zips/plat_forms_2011)
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 471 | 384 | 14 | 50 | 3 | 5 |
| Helpers | 41 | 38 | 0 | 5 | 0 | 5 |
| Models | 522 | 416 | 11 | 45 | 4 | 7 |
| Libraries | 30 | 27 | 1 | 3 | 3 | 7 |
| Integration tests | 64 | 49 | 3 | 1 | 0 | 47 |
| Functional tests | 592 | 478 | 8 | 1 | 0 | 476 |
@thieso2
thieso2 / gist:785880
Created January 19, 2011 08:42
crunde init script for solr (bundled with sunspot)
We couldn’t find that file to show.
New file: inline_levenshtein
inline do |builder|
builder.add_link_flags '-lruby'
builder.c_raw <<-EOT
long minimum(long a,long b,long c)
/*Gets the minimum of three values*/
{
long min=a;
if(b<min)
diff --git a/ext/perftools.c b/ext/perftools.c
index e6f97f1..ace2e01 100644
--- a/ext/perftools.c
+++ b/ext/perftools.c
@@ -159,6 +159,8 @@ static VALUE Isend;
case VM_FRAME_MAGIC_CFUNC:
self = cfp->self;
#ifdef HAVE_METHOD_H
+ if (! cfp->me) break;
+
[mysqld]
max_allowed_packet      = 16M
innodb_file_per_table
query_cache_size = 32M
innodb_additional_mem_pool_size = 256M
innodb_buffer_pool_size = 512M
innodb_log_buffer_size = 256M
innodb_log_file_size = 256M
#bulk_insert_buffer_size = 256M
innodb_flush_method = O_DSYNC