Skip to content

Instantly share code, notes, and snippets.

View skrzyneckik's full-sized avatar

Krzysztof Skrzynecki skrzyneckik

  • triOpsis Ltd
  • Leiden, Netherlands
View GitHub Profile
@ZacSweers
ZacSweers / OkioAtomicFile.kt
Created September 16, 2018 06:02
Okio/AtomicFile interop kotlin extensions
import android.util.AtomicFile
import okio.Buffer
import okio.Sink
import okio.sink
import okio.source
import java.io.FileOutputStream
import java.io.IOException
fun AtomicFile.source() = openRead().source()
@timja
timja / jenkins-dump-credentials.groovy
Last active November 22, 2024 16:29
Dump jenkins credentials - use in script console
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import org.jenkinsci.plugins.plaincredentials.impl.*
// def item = Jenkins.instance.getItem("your-folder")
@sonnguyen0310
sonnguyen0310 / gist:6720cbf39ce877c20fea1a987543fb99
Created July 2, 2018 08:31
iOS 11: Change size of UIBarButtonItem (image) in Swift 3
func setUpMenuButton(){
let menuBtn = UIButton(type: .custom)
menuBtn.frame = CGRect(x: 0.0, y: 0.0, width: 20, height: 20)
menuBtn.setImage(UIImage(named:"menuIcon"), for: .normal)
menuBtn.addTarget(self, action: #selector(vc.onMenuButtonPressed(_:)), for: UIControlEvents.touchUpInside)
let menuBarItem = UIBarButtonItem(customView: menuBtn)
let currWidth = menuBarItem.customView?.widthAnchor.constraint(equalToConstant: 24)
currWidth?.isActive = true
let currHeight = menuBarItem.customView?.heightAnchor.constraint(equalToConstant: 24)
@dstroot
dstroot / handlers.go
Last active April 10, 2023 13:22 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"io"
"net/http"
"sync/atomic"
)
func index() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@chrismarksus
chrismarksus / Dockerfile
Created November 14, 2017 21:22
docker for slack-export-viewer
FROM python:3
MAINTAINER Chris Marks
ENV HOST=0.0.0.0
ENV PORT=5000
WORKDIR /app
EXPOSE ${PORT}
@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@Gnzlt
Gnzlt / ResourceUtil.java
Created November 2, 2016 14:25
Android utils class to get a Bitmap from a VectorDrawable Resource Id (Took from http://qiita.com/konifar/items/aaff934edbf44e39b04a)
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.graphics.drawable.VectorDrawableCompat;
@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@keitaito
keitaito / GetValueFromCFDictionaryRef.m
Created March 9, 2016 08:45
Get value from CFDictionaryRef by converting it to NSDictionary.
+ (NSString *)getValueFromCFDictionaryRef {
// Assume you have record ID.
NSInteger recordID;
// Get a person record.
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, recordID);
// Get addresses data from person. Watch out it's a multi-value property.
ABMultiValueRef addresses = ABRecordCopyValue(person, kABPersonAddressProperty);
// Get the first one. Convert it from CFDictionaryRef to NSDictionary.
NSDictionary *address = (NSDictionary *)CFBridgingRelease(ABMultiValueCopyValueAtIndex(addresses, 0));