Skip to content

Instantly share code, notes, and snippets.

View osmanmesutozcan's full-sized avatar
♻️

Osman Mesut OZCAN osmanmesutozcan

♻️
View GitHub Profile
@osmanmesutozcan
osmanmesutozcan / ZoomableView.swift
Created January 10, 2024 11:14
Use UIKit gestures on SwiftUI Views
struct ZoomableView<Content: View>: UIViewControllerRepresentable {
let gestures: [ZoomableViewGestureType]
@ViewBuilder let content: () -> Content
func makeUIViewController(context: Context) -> ZoomableViewController<Content> {
let vc = ZoomableViewController<Content>()
vc.gestures = gestures
vc.child = UIHostingController(rootView: content())
return vc
/**
* Register a callback to trigger when we detect a click outside of refs.
*/
export function useDetectClickOutside(refs, callback) {
useEffect(() => {
const handleMouseDown = (e) => {
const clickOutsideOfRefs =
refs.every((r) => r.current) &&
refs.every((r) => !r.current.contains(e.target));
@osmanmesutozcan
osmanmesutozcan / timescale--db--backend--base.py
Created September 24, 2020 16:50 — forked from dedsm/timescale--db--backend--base.py
WeRiot Django Timescale integration
import logging
from django.contrib.gis.db.backends.postgis.base import \
DatabaseWrapper as PostgisDBWrapper
from django.db import ProgrammingError
from .schema import TimescaleSchemaEditor
logger = logging.getLogger(__name__)
@osmanmesutozcan
osmanmesutozcan / db.py
Last active September 22, 2020 12:55
Django ORM manager for (naive) bulk upserting
from django.db import models
class BulkUpsertManager(models.Manager):
@staticmethod
def __filter_field(field):
return not field.many_to_many
@staticmethod
def __to_serialized(field):
@osmanmesutozcan
osmanmesutozcan / minimal_ghc_ghcjs_nix.sh
Created June 3, 2020 12:44 — forked from louispan/minimal_ghc_ghcjs_nix.sh
Install Cabal, GHC, or GHCJS with one Nix command
# install nix (5.5 mins)
curl https://nixos.org/nix/install | sh
# open a new shell to source nix
bash
# query available haskell compilers
nix-env -qaP -A nixpkgs.haskell.compiler [QUERY]
# install ghc (2.5 mins, cached binary)
v -0.000581696 -0.734665 -0.623267
v 0.000283538 -1 0.286843
v -0.117277 -0.973564 0.306907
v -0.382144 -0.890788 0.221243
v -0.247144 -0.942602 0.276051
v -0.656078 -0.718512 -0.109025
v -0.609847 -0.786562 0.0198068
v -0.66248 -0.632053 -0.244271
v -0.511812 -0.845392 0.127809
v -0.609326 -0.569868 -0.41571
@osmanmesutozcan
osmanmesutozcan / client.py
Last active January 20, 2018 03:36
Handy tool for setting up and using shadowsocks on linux
#!/usr/bin/env python3
"""
WORKING:
- runs shadowsocks and http proxy clients
- redirects all traffic to ss-redir (port 1080) using iptables
- exposes local socks5 (port 1081) and http server (port 8118)
WIP:
- tor layer is still work in progress
@osmanmesutozcan
osmanmesutozcan / Readme.md
Last active March 19, 2018 12:56 — forked from oozliuoo/Readme.md
CeleryPipelineDemo

Quick demo of implementing pipelines via Celery

How to use

  1. Install Celery and Redis
  2. Start your redis locally
  3. Run three workers with name worker1@localhost, worker2@localhost and worker3@localhost
  4. Run the main.py

Improvements made to the original version