Skip to content

Instantly share code, notes, and snippets.

View Xiphe's full-sized avatar
💜

Hannes Diercks Xiphe

💜
View GitHub Profile
@Xiphe
Xiphe / day1_1.js
Last active December 8, 2023 22:50
Advent Of Code 2023 in JS without keywords and reassignments
`1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet`
.split("\n")
.reduce(
(sum, line) =>
sum +
parseInt(
(line + line)
@Xiphe
Xiphe / autoedit.zsh
Last active July 6, 2023 07:17
Scripts for automating my video-cutting stuff
#!/bin/zsh
zmodload zsh/datetime
# INPUTS
INPUT_FILE=$1
START_TIME=$2
if [ -n "$3" ]; then
CUT_END=$3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Xiphe
Xiphe / wtf.md
Last active March 26, 2019 12:41
WTF moments when introducing someone to JS
  1. (about babel/typescript) so you compile JavaScript to other JavaScript so that can be sent to the browser which compiles it again to machine code?
  2. you can export default function foo() {} in foo.js and then import bar from './foo.js'
@Xiphe
Xiphe / bookmarklet-remove-unreachable-refs.js
Last active May 23, 2017 07:13
simple script that gets rid of unreachable references in issues and pull requests
javascript: (function(){var a=null;document.querySelectorAll('a.js-selected-navigation-item').forEach(function(b){'Code'===b.innerText.trim()&&(a=b.href)}),document.querySelectorAll('.discussion-item-ref').forEach(function(b){var c=b.querySelector('.commit-meta a');c&&window.fetch(a+'/branch_commits/'+c.innerText).then(function(d){return d.text()}).then(function(d){d.trim().length||b.remove()})})})();
@Xiphe
Xiphe / jsx-it-markdown+react-jsx.js
Created January 16, 2017 23:54
seamlessly embedded JSX in markdown files on the fly #hipsterstuff
'use strict';
const md = require('markdown-it')();
const mdJsxPlugin = require('markdown-it-jsx');
const reactJsx = require('react-jsx');
const React = require('react');
const reactDom = require('react-dom/server');
const originalCreateElement = React.createElement;
@Xiphe
Xiphe / v1.0-karma1.md
Last active March 8, 2016 16:47
Love and Peace Clause

love and peace

[![love and peace](https://img.shields.io/badge/%F0%9F%92%9B%E2%9C%8C%EF%B8%8F-v1.0--karma1-c28fcc.svg)](https://gist.github.com/Xiphe/aa89d804f8137c963d27)

LOVE AND PEACE

Dieses Produkt wurde in der Überzeugung geschrieben, gestaltet oder anderweitig hergestellt, dass wir die Welt durch Liebe und Frieden zu einem besserem Ort machen können.

@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);

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');

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