Skip to content

Instantly share code, notes, and snippets.

View cmfcmf's full-sized avatar
🚂
Outside of my work for @google, I may be slow to respond.

Christian Flach cmfcmf

🚂
Outside of my work for @google, I may be slow to respond.
View GitHub Profile
@jupdike
jupdike / IntersectTwoCircles.js
Last active October 17, 2024 13:10
Find the intersections (two points) of two circles, if they intersect at all
// based on the math here:
// http://math.stackexchange.com/a/1367732
// x1,y1 is the center of the first circle, with radius r1
// x2,y2 is the center of the second ricle, with radius r2
function intersectTwoCircles(x1,y1,r1, x2,y2,r2) {
var centerdx = x1 - x2;
var centerdy = y1 - y2;
var R = Math.sqrt(centerdx * centerdx + centerdy * centerdy);
if (!(Math.abs(r1 - r2) <= R && R <= r1 + r2)) { // no intersection
@shah743
shah743 / twitter_widget_id_extractor.rb
Last active May 11, 2016 14:42
Get twitter embed widget's ID dynamically
class TwitterWidgetIdExtractor
WIDGET_SETTING_URL = "https://twitter.com/settings/widgets/new/user?screen_name="
SIGNIN_URL = "https://twitter.com/login"
attr_accessor :screen_name, :twitter_username, :twitter_password
def initialize(screen_name, twitter_username, twitter_password)
@screen_name = screen_name
@twitter_username = twitter_username
@twitter_password = twitter_password
@cmfcmf
cmfcmf / Cut video from Ubuntu command line
Last active August 29, 2015 13:56
Cut video from Ubuntu command line, taken from here: http://askubuntu.com/a/59388/161884
mencoder -ss 00:30:00 -endpos 00:00:05 -oac copy -ovc copy originalfile -o newfile
@cmfcmf
cmfcmf / Ubuntu - Bilder um die Hälfte verkleinern
Last active January 4, 2016 15:09
Ubuntu - Bilder um die Hälfte verkleinern
mogrify -resize 50% -format jpg *
convert test.gif test%05d.jpg
ffmpeg -r NUMBER_OF_JPG_PICTURES_GENERATED -i test%05d.jpg -y -an test.avi
@rrosiek
rrosiek / install_mysql.sh
Last active October 1, 2024 03:05
Vagrant provision script for php, Apache, MySQL, phpMyAdmin, Laravel, and javascript helpers. Tested with Ubuntu 16.04.
#! /usr/bin/env bash
###
#
# install_mysql.sh
#
# This script assumes your Vagrantfile has been configured to map the root of
# your application to /vagrant and that your web root is the "public" folder
# (Laravel standard). Standard and error output is sent to
# /vagrant/vm_build.log during provisioning.
@cmfcmf
cmfcmf / Update, edit and develop Tumblr Theme dynamically.js
Last active July 29, 2019 15:39
Creating and developing own tumblr themes has always been a pitty. However, this single line of javascript will help you A LOT. Follow the instuctions in the first comment below to get your own live version of your theme.
setInterval(function(){jQuery.ajax('YOUR-URL-TO-THE-THEME-FILE',{cache:false}).success(function(html){var btn=jQuery("div[data-action='update_preview']").first();if(html!=ace.edit('editor').getValue()){ace.edit('editor').setValue(html);if(!btn.hasClass('disabled'))btn.click()}});},1000);
@cmfcmf
cmfcmf / gist:6396836
Created August 31, 2013 07:58
Linux Search And Replace Source: http://stackoverflow.com/a/8588807/2560557

For the file file.txt:

sed -i 's/abc/abcd/g' file.txt

For all files in the current folder:

find . -maxdepth 1 -type f -exec sed -i 's/abc/abcd/g' {} \;

For the files in the current directory and all subdirectories:

@cmfcmf
cmfcmf / admin_admin_ajax.js
Created August 24, 2013 17:22
Fixed extmenu drag and drop - Zikula 1.3.5 and 1.3.6. Replace the file `admin_admin_ajax.js` in `system/Admin/javascript` with the file below.
// Copyright Zikula Foundation 2010 - license GNU/LGPLv3 (or at your option, any later version).
Zikula.define("AdminPanel");Zikula.AdminPanel.labels={clickToEdit:Zikula.__("Right-click down arrows to edit tab name"),edit:Zikula.__("Edit category"),remove:Zikula.__("Delete category"),makeDefault:Zikula.__("Make default category"),saving:Zikula.__("Saving")};Zikula.AdminPanel.setupNotices=function(){var b={headerSelector:"strong",headerClassName:"z-systemnoticeheader z-panel-indicator",effectDuration:0.5},a=$$("#z-developernotices ul:first");if($("z-securityanalyzer")){b.active=[0]}Zikula.AdminPanel.noticesPanels=new Zikula.UI.Panels("admin-systemnotices",b);if(a[0]){a[0].removeClassName("z-hide")}};Zikula.AdminPanel.Tab=Class.create({initialize:function(b,a){if(a){this.tab=this.createTab(a)}else{this.tab=$(b)}this.id=/admintab_(\d+)/.exec(this.tab.identify())[1];this.attachActionsMenu();this.attachModulesMenu();this.attachEditor();Droppables.add(this.tab.down("a"),{accept:"draggable",hoverclass:"ajaxhover",on
@cmfcmf
cmfcmf / User.php
Created July 29, 2013 16:44
New User.php file to use with Zikula 1.3.5 and the OpenID module.
<?php
/**
* Copyright Zikula Foundation 2009 - Zikula Application Framework
*
* This work is contributed to the Zikula Foundation under one or more
* Contributor Agreements and licensed to You under the following license:
*
* @license GNU/LGPLv3 (or at your option, any later version).
* @package Zikula
* @subpackage Users