Skip to content

Instantly share code, notes, and snippets.

View ustun's full-sized avatar

Ustun Ozgur ustun

View GitHub Profile
@ustun
ustun / gist:93f61be83a138533e0e91249020e57a7
Last active June 27, 2017 16:39
Postgresql citext support with Clojure JDBC + Postgres
;; citext with JDBC
;; Using the technique at: http://hiim.tv/clojure/2014/05/15/clojure-postgres-json/
(import 'org.postgresql.util.PGobject)
(extend-protocol j/IResultSetReadColumn
PGobject
(result-set-read-column [pgobj metadata idx]
(let [type (.getType pgobj)
@ustun
ustun / gitlab_ci.md
Last active March 29, 2022 17:29
Running multiple GitLab CI runners

Running multiple GitLab CI runners as normal users

Option 1: Using system level service

  1. Install gitlab multi runner systemwide: https://docs.gitlab.com/runner/install/
  2. Register the runner as an unpriviledged user (paste the secret key in your repo's runners page). This should create your configuration config (toml) file. gitlab-runner register
  3. Register the service as root user by passing the path to the toml file and the user flag and the service name (needs to be unique per user or runner).

gitlab-runner install --config /home/myuser/.gitlab-runner/config.toml --user myuser --working-directory /home/myuser --service myuser_gitlabrunner

@ustun
ustun / templateorg
Created November 14, 2016 15:51
Org Template for xelatex
#+TITLE: My Document Title
#+AUTHOR: My Name
#+DATE: Some Date
#+OPTIONS: toc:nil num:nil
# no table of contents
#+LATEX_COMPILER: xelatex
# Or M-x customize-variable org-latex-compiler
import asyncio
import requests
def get_that_does_not_fail(url):
try:
response = requests.get(url)
return {"success": True, "response": response}
except Exception as e:
return {"success": False, "error": e, "url": url}
(defun save-text-scale ()
"Save text-scale."
(message "saving prev text scale %d" text-scale-mode-amount)
(setq text-scale-previous (buffer-local-value 'text-scale-mode-amount (current-buffer))))
(add-hook 'before-revert-hook 'save-text-scale)
(defun restore-text-scale ()
"Restore text-scale."
(message "restoring prev text scale %d" text-scale-previous)
{
"profiles": [
{
"name": "Default profile",
"selected": true,
"simple_modifications": {
"caps_lock": "right_control",
"right_option": "right_control"
@ustun
ustun / matching_view_func_middleware.py
Created August 25, 2016 12:59
If the response is a json object, outputs the matched func, file name and line no
class MatchingViewFuncMiddleware(object):
def process_request(self, request):
pass
def process_response(self, request, response):
if 'content-type' in response._headers and \
response._headers['content-type'][1].startswith('application/json') and \
response.status_code == 200:
ag '^[ \t]+from ' questions | grep -v django | grep -v vendor | grep -v 'from questions'
@ustun
ustun / parse5spice.m
Created August 16, 2016 23:29
Parses (imports) 5Spice data to MATLAB
function parse5spice(filename)
% PARSE5SPICE Parses the data in the Report tab of the 5Spice software and
% imports it into MATLAB workspace
% Call the function with an optional filename. If no filename is specified,
% a data.txt in the same directory is used.
% To create data.txt, right click in 5Spice in the Report tab, click Select
% All, and Copy and paste into an empty file. Then, save data as data.txt
% in the same directory
@ustun
ustun / flow_func.js
Created August 16, 2016 18:15
Function type declaration for flowtype
//@flow
// define the function type
type FunctionThatTakesAStringAndReturnsANumber = (x: string) => number;
function higherOrderFunction(myFn: FunctionThatTakesAStringAndReturnsANumber) {
return "something";
}