Skip to content

Instantly share code, notes, and snippets.

@petrprikryl
petrprikryl / function.py
Last active June 26, 2023 06:31
Django table function
#############################
# Table Functions
#############################
'''
CREATE OR REPLACE FUNCTION get_user(INTEGER DEFAULT NULL, VARCHAR DEFAULT NULL)
RETURNS TABLE(
id INTEGER,
user_id INTEGER,
one_id INTEGER,
username VARCHAR,
@micheltlutz
micheltlutz / Border in TableView Sections
Last active January 29, 2024 19:08
Apply border around tableView Sections
/**
Extension for UITableViewController or UIViewController as you prefer
*/
extension UITableViewController {
func colorSection(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let cornerRadius: CGFloat = 0.0
cell.backgroundColor = UIColor.clear
let layer: CAShapeLayer = CAShapeLayer()
let pathRef: CGMutablePath = CGMutablePath()
//dx leading an trailing margins
@bacilla-ru
bacilla-ru / zeal_docsets_update.py
Last active November 13, 2021 18:35
Update installed Zeal (https://github.com/zealdocs/zeal) docsets.
#!/usr/bin/env python3
import json
import os
import os.path
import shutil
import sys
import tarfile
import tempfile
import typing
import xml.etree.ElementTree as ET
@Chrisb616
Chrisb616 / catchWarningsAndErrors.sh
Created October 3, 2016 18:28
Catch Warning and Error Comments During Build
TAGS="TODO:|FIXME:"
ERRORTAG="ERROR:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/"
@helena
helena / TrySamples.scala
Last active July 13, 2021 15:03
Try introduced in Scala 2.10.0
// Start by adding these
import scala.util.{ Try, Success, Failure }
/**
* Sample runs code that raises the exception:
* java.lang.ArithmeticException: / by zero
*/
object Sample {
def main(args: Array[String]): Unit = {
@andrewgleave
andrewgleave / iOSMapKitFitAnnotations.m
Last active May 17, 2024 02:07
Zooms out a MKMapView to enclose all its annotations (inc. current location)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}