Skip to content

Instantly share code, notes, and snippets.

View ustun's full-sized avatar

Ustun Ozgur ustun

View GitHub Profile
{
"profiles": [
{
"name": "Default profile",
"selected": true,
"simple_modifications": {
"caps_lock": "right_control",
"right_option": "right_control"
(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)
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}
@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
@ustun
ustun / gitlab_ci.md
Last active May 21, 2024 07:57
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 / 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 / reducer_as_immutable_class.js
Created February 6, 2017 09:56
redux reducer from immutable class
var camelCase = require('lodash.camelcase');
const {Map, Record, List} = require('immutable');
class Todo extends Record({ description: null, completed: false }) {
toggle() {
return this.set('completed', !this.completed);
}
}
const InitialTodoApp = Record({
(update-in foo [:bar :baz] ....)
What I meant was, each part of the path does an equality check of the original
compound data structure.
So, it says, give me the subsection of foo where key is *equal to* :bar.
Here, the predicate that says "key being equal to" is hard-coded.
Let's say we have a feed of questions and each question has an answer, and each answer has an id.
We want to find the answer with id=5 and update its like count.
Assume the data structure is nested, so
(def feed (atom {:questions [{:id 1 :answers [{:id 5, text: 'foo', :like-count 4}]}]})
If I know that the answer I'm targeting is at 0th position of 0th question, I can do:
(swap! feed update-in [:questions 0 :answers 0 :like-count] inc)
@ustun
ustun / gist:0aa6885cbf003e65e3f44a3ba254fc77
Created March 21, 2017 09:52
Hickey on Levelling Up as a Programmer
From https://disqus.com/home/discussion/jasonrudolph/jasonrudolph_blog_programming_achievements_how_to_level_up_as_a_developer/newest/#comment-287120251
Rich Hickey • 6 years ago
Sorry, I have to disagree with the entire premise here.
A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.
Mastery comes from a combination of at least several of the following: