Skip to content

Instantly share code, notes, and snippets.

View akarca's full-sized avatar
🏠
Working from home

Serdar Akarca akarca

🏠
Working from home
View GitHub Profile
@majek
majek / udp_server.py
Created February 8, 2012 00:48
Simple python udp server
import logging
import socket
log = logging.getLogger('udp_server')
def udp_server(host='127.0.0.1', port=1234):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@dtao
dtao / example.sublime-keymap
Last active December 19, 2017 22:58
Sublime Text plugin to replace selected text with random letters/numbers
[
{ "keys": ["ctrl+alt+r"], "command": "randomize" }
]
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@uupaa
uupaa / ios.xcode.md
Last active January 28, 2020 09:36
iOS device spec, versions and Xcode deployment target information

iOS Devices

Device CPU GPU Display OpenGL
iPod touch 4 A4 PowerVR SGX535 960 x 640 2.1
iPod touch 5 A5 PowerVR SGX543MP2 1136 x 640 2.1
iPad 1 A4 PowerVR SGX535 1024 x 768 2.1
iPad 2 A5 PowerVR SGX543MP2 1024 x 768 2.1
iPad 3 A5X PowerVR SGX543MP4 2048 x 1536 2.1
iPad 4 A6X PowerVR SGX554MP4 2048 x 1536 2.1
@mrchrisadams
mrchrisadams / auto_activation.fish
Last active October 13, 2021 12:47
virtual environments with python and fish
################
# Automatic activation
if not set -q VIRTUALFISH_ACTIVATION_FILE
set -g VIRTUALFISH_ACTIVATION_FILE .venv
end
function __vfsupport_auto_activate --on-variable PWD
if status --is-command-substitution
return
@benjamincharity
benjamincharity / contacts.js
Last active January 9, 2023 16:06
Create a downloadable file of VCARD formatted address for iOS from a JSON array.
var contacts =
[
{
"notes": [
{
"description": "Fugiat aute pariatur excepteur elit."
}
],
"tels": [
{
@britzl
britzl / timer.lua
Last active February 13, 2018 14:18
Timer module that can be used to get a callback when a certain amount of time has elapsed
--- Module that can be used to get a callback when a certain amount of time has elapsed
--
-- @usage
-- local timer = require "timer"
-- function init(self)
-- self.t1 = timer.seconds(2, function()
-- print("2 seconds have elapsed")
-- end)
-- self.t2 = timer.seconds(5, function()
-- print("5 seconds have elapsed")
@toringe
toringe / cidr.py
Created October 22, 2015 10:28
Merge CIDR blocks into super blocks if possible
#!/usr/bin/env python
#
# Example 1: All blocks in list.txt, one CIDR per line
# cat list.txt | cidr.py
#
# Example 2: Echo CIDR blocks to stdout
# echo 1.2.3.0/25 1.2.3.128/25 | cidr.py
import sys
from netaddr import *
@dingzeyuli
dingzeyuli / copy
Created November 11, 2016 15:33
Faster and more efficient alternative to scp for file copying
#!/bin/sh
# whenever you use "scp", use "copy" instead, it ignores duplicate files.
rsync -azhe ssh --progress $1 $2
@simme
simme / debounce-throttle.swift
Created December 20, 2016 10:04
Swift 3 debounce & throttle
//
// debounce-throttle.swift
//
// Created by Simon Ljungberg on 19/12/16.
// License: MIT
//
import Foundation
extension TimeInterval {