Skip to content

Instantly share code, notes, and snippets.

@dotob
dotob / yaml
Created September 4, 2019 13:51
sample yaml
# this job builds the project and its dependencies
r4c:
stage: build
image: node:8
# only:
# changes:
# - r4c/**/*
# - types/**/*
script:
- yarn run writeVersions
@dotob
dotob / sedoneliners.txt
Created June 8, 2017 11:48
sed one liners
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
@dotob
dotob / index.ts
Created September 16, 2016 13:48
express route per typescript decorator
import * as express from 'express';
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
@dotob
dotob / checkmysql
Created May 16, 2016 20:01
small script to check if mysql is running and restart it if not
echo "check mysql"
service mysql status | grep -qE [0-9]{5}
if [ $? -eq 0 ]; then
echo OK
else
service mysql start
echo "-" | mail -s "fringshaus.de mysql restarted" -r sk@dotob.de sk@dotob.de
echo "mysql restarted, mail sent"
fi
@dotob
dotob / nojquery_table_select.html
Created February 11, 2016 08:59
select rows and columns in html without jquery
<html>
<head>
<title>brand</title>
<style>
.selected {background-color: lightgrey;}
table {border:1px solid black;}
td {border:1px solid black;}
</style>
<script type="text/javascript">
// ready func for knowing when document is ready
@dotob
dotob / d3-server.coffee
Created January 6, 2016 14:12
Directly render and serve d3 visualizations from a nodejs server.
# Start `coffee d3-server.coffee`
# Then visit http://localhost:1337/
# originally from: https://gist.github.com/Caged/6407459
d3 = require('d3')
http = require('http')
jsdom = require('jsdom')
http.createServer((req, res) ->
# Chrome automatically sends a requests for favicons
# Looks like https://code.google.com/p/chromium/issues/detail?id=39402 isn't
@dotob
dotob / gist:4034731
Created November 7, 2012 21:51
teamcity sample artifact vs. buildinfo
private Uri CreateArtefactUri(Build build) {
string finalArtifactName = string.Empty;
try {
string artifactInfoUriString = string.Format("http://{0}/guestAuth/repository/download/{1}/{2}/teamcity-ivy.xml", this.teamCityHost, this.buildType, build.Number);
using (WebClient wc = new WebClient()) {
var artefactInfo = wc.DownloadString(artifactInfoUriString);
XDocument artifactInfoXmlDoc = XDocument.Parse(artefactInfo);
foreach (var artifactElement in artifactInfoXmlDoc.Element("ivy-module").Element("publications").Elements("artifact").Where(e => e.Attribute("ext").Value == "exe")) {
var artifactName = artifactElement.Attribute("name").Value;
if (Regex.IsMatch(artifactName, this.artifactNameMatch)) {
@dotob
dotob / transferhandler
Created August 15, 2012 20:14
filedragdrop handler
// imports omitted, dont know why...
public class Foo extends TransferHandler {
//.../*DRAG &amp;amp; DROP*/
@Override
public boolean importData(JComponent comp, Transferable t) {
// Make sure we have the right starting points
if (!(comp instanceof JTextField)) {
return false;
}
@dotob
dotob / rss2uli.rb
Created June 12, 2012 10:32
rss parsing with ruby and simplerss
require 'simple-rss'
require 'open-uri'
class RssReader
def parseFeed (url, length)
feed_url = url
result = SimpleRSS.parse open(feed_url)
output = "<html><meta charset=\"utf-8\"><body>";
output += "<h1>#{result.channel.title}</h1><br />"
result.items.each_with_index do |item, i|