Skip to content

Instantly share code, notes, and snippets.

View guinslym's full-sized avatar

Guinslym guinslym

View GitHub Profile
@guinslym
guinslym / nginx-centos7.yml
Created April 3, 2021 11:52 — forked from icasimpan/nginx-centos7.yml
Sample ansible playbook to install nginx with sample page on CentOS7
## Credits to John Lieske - https://www.ansible.com/blog/getting-started-writing-your-first-playbook
---
- name: Install nginx
hosts: host.name.ip
become: true
tasks:
- name: Add epel-release repo
yum:
name: epel-release
@guinslym
guinslym / zoom.py
Created March 31, 2021 09:49
OpenCV Python Video Zoom Function by clicking mouse
# Author: Noche, Kaiseir Josephus B.
import numpy as np
import cv2
### DEFINED FUNCTIONS ################################
def mousecall(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDBLCLK:
zoomin(x,y)
@guinslym
guinslym / latency.markdown
Created May 17, 2020 16:05 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@guinslym
guinslym / latency.txt
Created May 17, 2020 16:04 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Login Example',
@guinslym
guinslym / 1_nanobox_cli.sh
Created November 10, 2017 11:17 — forked from LeCoupa/1_nanobox_cli.sh
Nanobox Cheatsheet: CLI commands and Boxfile --> https://github.com/LeCoupa/awesome-cheatsheets
# *****************************************************************************
# UPDATED VERSION AVAILABLE HERE:
# https://github.com/LeCoupa/awesome-cheatsheets/blob/master/tools/nanobox_cli.sh
# *****************************************************************************
# *****************************************************************************
# LOCAL ENVIRONMENT
# *****************************************************************************
#!/usr/bin/python
import mechanize
import itertools
br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
@guinslym
guinslym / postgres_guide
Created August 25, 2017 22:50 — forked from tacionery/postgres_guide
install postgresql on antergos
# uninstall postgresql if necessary
$ sudo pacman -R postgresql postgresql-libs
# remove postgres files
$ sudo rm -rfv /var/lib/postgres
# proceed with the installation
$ sudo pacman -S postgresql postgresql-libs
# setup password for postgres
$ sudo passwd postgres
@guinslym
guinslym / check-author-mixin.py
Created July 29, 2017 08:14 — forked from mmartinez/check-author-mixin.py
This mixin checks if the object being updated belongs to the current user.
# -*- coding: utf-8 -*-
from django.http.response import HttpResponseForbidden
class AuthorRequiredMixin(object):
def dispatch(self, request, *args, **kwargs):
obj = self.get_object()
if obj.user != self.request.user:
return HttpResponseForbidden()