Skip to content

Instantly share code, notes, and snippets.

View Xiphe's full-sized avatar
🏥
Dealing with Life

Hannes Diercks Xiphe

🏥
Dealing with Life
View GitHub Profile
@Xiphe
Xiphe / index.html
Last active December 18, 2015 08:49
Parameterübergabe an Popups
<html>
<head>
<title>Parameter Uebergabe JS</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#preview_link').click(function(event) {
event.preventDefault();
var popup = window.open(
'preview.html',
@Xiphe
Xiphe / index.html
Created June 11, 2013 12:57
Alternative Parameterübergabe an popups
<html>
<head>
<title>Parameter Uebergabe JS</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#preview_link').click(function(event) {
event.preventDefault();
var popup = window.open(
'preview.php?'+$('#form').serialize(),
@Xiphe
Xiphe / auto_ignore_sass.rb
Last active December 30, 2015 00:39
Create .gitignore for parsed sass files. When using css, less and sass side by side and all css files are in the same folder (even the ones created by sass) this is a way to prevent the generated files from being checked in into your repository.
##### automatically create a .gitignore containing all created css files inside the css folder.
# Absolute path to css dir
abs_css_dir = File.absolute_path(css_dir) + '/'
# .gitignore File instance
gitignore_file = File.open(css_dir + '/.gitignore', 'a+')
gitignore_lines = gitignore_file.readlines
# banner for gitignore file.
gitignore_banner = <<-eos
{
"Handwriting": [
"Patrick Hand SC",
"Grand Hotel",
"Calligraffitti",
"Coming Soon",
"Crafty Girls",
"Homemade Apple",
"Just Another Hand",
"Montez",
@Xiphe
Xiphe / MyClass.js
Created July 9, 2014 22:38
Thoughs about angular/di.js@2.0 and DRY
/**
* Just a simple example Class
* Main point here is: This is completely independent from di implementations
* We could as well require this file and instantiate the Class on our own
*/
function MyClass(myOtherClass, readFile) {
this.myOtherClass = myOtherClass;
this.readFile = readFile;
this.doThings = function() {};
}
@Xiphe
Xiphe / bower.json
Last active August 29, 2015 14:04
Moar Jasmine 2.0 matchers
{
"name": "jasmine-moar-matchers",
"authors": [
"Hannes Diercks"
],
"description": "Some additional Jasmine 2.0 Matchers.",
"main": ["toBeInstanceOf.js", "toBeTypeOf.js", "promises.js"],
"keywords": [
"jasmine",
"matcher"
@Xiphe
Xiphe / script.js
Created April 3, 2015 12:24
Elevator Saga
{
init: function(elevators, floors) {
function unique(arr) {
var a = arr.concat();
for(var i=0; i<a.length; ++i) {
for(var j=i+1; j<a.length; ++j) {
if(a[i] === a[j])
a.splice(j--, 1);
}
}

Remove /bower_components/ from github diff

Array.prototype.forEach.call(document.querySelectorAll('[title*="/bower_components/"]'), function(node){
  node.parentNode.parentNode.parentNode.remove();
});

Bookmarklet can be found after this link: http://xiphe.net/remove_bower_components_bookmarklet.html

How to use require in angular 1.x modules

  • embrace module structure (1x require = module is available)
// my/app.js
require('../dep/app');
angular.module('myApp', ['dep']);
require('./value');
@Xiphe
Xiphe / jquery.bridge.js
Created July 28, 2015 15:17
jquery-ui-like bridge for jquery plugins
/** @const */
var PLUGIN_NAME = 'myPlugin';
$.fn[PLUGIN_NAME] = function(options) {
var $els = this;
/* Method call: */
if (typeof options === 'string') {
var methodName = options;
var args = Array.prototype.slice.call(arguments, 1);