Skip to content

Instantly share code, notes, and snippets.

View Cloudo's full-sized avatar

сloudo Cloudo

View GitHub Profile
@Cloudo
Cloudo / limit.py
Created February 12, 2016 06:49 — forked from hartror/limit.py
Finding safe ways to limit a forked proccess's memory in Python.
#!/usr/bin/env python
import os
import psutil
import resource
import subprocess
import sys
import time
@Cloudo
Cloudo / paginators.py
Created March 17, 2016 14:45
Django Paginators
from django.core.cache import caches
from django.core.paginator import Paginator
from django.db import connections
class LargeTablePaginator(Paginator):
"""
Overrides the count method to get an estimate instead of actual count when not filtered
"""
def _get_count(self):
"""
#Script to set custom iprange for dockers bridge, also starts docker
cat << EOF >> /etc/rc.local
#docker
subnet="10.0.41.1/16"
if ! [[ "$(ip link show docker0)" ]]; then
ip link add docker0 type bridge
ip addr add "$subnet" dev docker0
ip link set docker0 up
iptables -t nat -A POSTROUTING -s "$subnet" ! -d "$subnet" -j MASQUERADE
hello
@Cloudo
Cloudo / fetch.jsx
Created March 6, 2018 15:20
fetch jsx
/* @flow */
import { handleActions, createAction } from 'redux-actions'
import { createNamedWrapperReducer } from 'utils/reducers'
const prefix = 'fetch'
/**
* FLOWTYPES
*/
export type Actions<Payload> = {
import React from 'react'
import { BooleanValue } from 'react-values'
import { css } from 'emotion'
import { Button, ConfirmDialog } from 'uikit'
import validate from './validate'
const SaveButtonWithDialog = ({ disabled, onConfirm, handleSubmit }) => (
<BooleanValue>
@Cloudo
Cloudo / utils.js
Created October 12, 2018 07:30
cypress utils
export const getElementById = q => Cypress.$(`#${q}`)[0]
export const getElementByName = q => Cypress.$(`[name="${q}"]`)[0]
export const getElement = q => getElementById(q) || getElementByName(q)
export const get = q => cy.get(`#${CSS.escape(q)}`)
export const uncheck = q => {
const checkbox = getElement(q)
if (checkbox && checkbox.checked) {
@Cloudo
Cloudo / git-timesheet.sh
Created November 1, 2018 08:07
bash script to log git commits grouped by day
#!/bin/bash
# Generates git changelog grouped by day
#
# optional parameters
# -a, --author to filter by author
# -s, --since to select start date
# -u, --until to select end date
git-timesheet () {
import { useEffect, useRef } from 'react'
import { isEqual } from 'lodash'
import { notice } from 'uikit'
import { handleFetchError } from 'utils/exceptions'
import { useSafeSetState } from './useSetState'
function usePrevious(value) {
const ref = useRef()
useEffect(() => {
import ReactSelect, { Props } from 'react-select'
import { customStyles, getTheme } from './styles'
import { ReactNode, useMemo } from 'react'
import { FormControl } from '../FormControl'
export const SelectRaw = (props: Props) => {
const theme = useMemo(() => getTheme(props.error), [props.error])
return (
<ReactSelect
classNamePrefix="react-select"