Skip to content

Instantly share code, notes, and snippets.

Avatar

Rudolf Farkas rudifa

  • Rudicubes (defunct)
  • Geneva, Switzerland
View GitHub Profile
@rudifa
rudifa / npm-scripts.py
Created Sep 25, 2020
In a node project, list scripts defined in package.json
View npm-scripts.py
#!/usr/bin/python3
"""
In a node project, list scripts defined in package.json
@rudifa Rudi Farkas 2020
"""
from os import path
import json
View dot-gitconfig
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[user]
name = ***
email = ***
[alias]
aliases = config --get-regexp alias
@rudifa
rudifa / registerXcode.sh
Created Apr 11, 2020
Xcode extensions disappeared after installation of an new Xcode version?
View registerXcode.sh
#!/bin/bash
# problem:
# you installed a new version of Xcode, and now the previously installed extensions are
# not visible any more in menus or accessible via custom keyboard shortcuts
# solution:
# https://nshipster.com/xcode-source-extensions/
# ... when multiple copies of Xcode are on the same machine, extensions can stop working completely. In this case, Apple Developer Relations suggests re-registering your main copy of Xcode with Launch Services.
View index.html
<!DOCTYPE html>
<html>
<body>
<todo-app></todo-app>
<script type="module">
import { LitElement, html } from 'https://unpkg.com/lit-element?module';
const author = 'open-wc';
const homepage = 'https://open-wc.org/';
View index.html
<!DOCTYPE html>
-
<html>
<body>
<style>
body {
font-family: monospace;
}
h1 { color: pink; }
@rudifa
rudifa / uiview_print_subviews.swift
Last active Jun 15, 2018
my_UIView.printSubviews()
View uiview_print_subviews.swift
import UIKit
extension UIView {
func printSubviews(indent: String = "") {
print("\(indent)\(self)")
let indent = indent + "| "
for sub in self.subviews {
sub.printSubviews(indent: indent)
}
@rudifa
rudifa / scope.py
Created Jul 7, 2016
scope.py emulates an oscilloscope
View scope.py
# scope.py v 0.1 by Rudi Farkas
# ref http://matplotlib.org/examples/animation/
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
class Scope():
@rudifa
rudifa / MakeNamedTuple.py
Last active Jan 6, 2016
Create a set of named values with a minimum of fuss (a python namedtuple)
View MakeNamedTuple.py
# Here is my variation on theme 'Create a set of named values with a minimum of fuss'
# Based on idea seen in https://gist.github.com/href/1319371
# Rudi Farkas 6 Jan 2016
from collections import namedtuple
def MakeNamedTuple(name='NamedTuple', **kwargs):
"""
Returns a namedtuple instance.
@rudifa
rudifa / format_rounded.py
Last active Aug 29, 2015
format_rounded.py
View format_rounded.py
# formatter for arrays of floating point numbers
# Rudi Farkas 8 Aug 2014
def format_rounded(float_arr, decimals=2, general=False, sep=', '):
"""
Formats elements of float_arr with the stated number of decimal digits,
in the fixed '%f' or general '%g' format.
Returns the element strings joined with the separator.
"""
return sep.join(['{:.{precision}{type}}'.format(x, precision=decimals, type='g' if general else 'f') for x in float_arr])
@rudifa
rudifa / test_floating_point_number_re_pattern.py
Last active Jul 7, 2016
define and test a regex pattern that matches valid floating point number strings
View test_floating_point_number_re_pattern.py
# test_floating_point_number_re_pattern.py
# Rudi Farkas 19 Nov 2013
import re
# define a regex pattern that matches valid floating point number strings
floating_point_number_re_pattern = fpn_rpat = "[-+]?\s*(?:\d+(?:\.(?:\d+)?)?|\.\d+)(?:[eE][-+]\d+)?"
if __name__ == '__main__':