Skip to content

Instantly share code, notes, and snippets.

View n1mh's full-sized avatar

Diego Martínez Castañeda n1mh

View GitHub Profile
@nealmcb
nealmcb / track_session_inhibitors.py
Created July 16, 2012 05:19
Track and print out the apps and clients that are inhibiting Gnome session actions like log out, user switching, suspending or idle/dpms/screensaver, under Linux.
#!/usr/bin/python
"""
Print out the apps and clients that are inhibiting session actions like log out, user switching, suspending or idle.
%InsertOptionParserUsage%
Example:
track_session_inhibitors &
Todo:
@rmpel
rmpel / diacritics-restore.sql
Last active March 13, 2018 16:15
Repair diacritics encoding in MySQL database. Replace table-name and field-name with UTF-8 capable editor (Sublime Text 3 is verified to not mess up the query)
update wp_posts set
post_content = replace(post_content, CONVERT(CAST(CONVERT('¡' USING utf8) AS BINARY) USING latin1), '¡'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('¢' USING utf8) AS BINARY) USING latin1), '¢'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('£' USING utf8) AS BINARY) USING latin1), '£'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('¤' USING utf8) AS BINARY) USING latin1), '¤'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('¥' USING utf8) AS BINARY) USING latin1), '¥'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('¦' USING utf8) AS BINARY) USING latin1), '¦'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('§' USING utf8) AS BINARY) USING latin1), '§'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('¨' USING utf8) AS BINARY) USING latin1), '¨'),
post_content = replace(post_content, CONVERT(CAST(CONVERT('©' USING utf8) AS BINARY) USING latin1), '©'),
....
Parameters:
....
CidrBlock:
Default: 172.21.0.0/16
Description: VPC Cidr Block
Type: String
AllowedPattern: "\\d+.\\d+.\\d+.\\d+/\\d+"
ConstraintDescription: Must be CIDR
Subnets:
@dave-malone
dave-malone / cloudformation_s3_serverside_encryption.yml
Created February 6, 2018 03:48
CloudFormation snippet to enable server side encryption by default on an s3 bucket
StaticAssetsS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-encrypted-bucket
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
VersioningConfiguration:
Status: Enabled
@rafatux
rafatux / gist:61fd665fc455e54d69ae14f2cf6e1d58
Last active October 30, 2019 15:45
Redimensiona un conjunto de jgp de una carpeta a otra a un tamaño especificado en vb.net
Imports System
Imports System.Drawing
Module Program
Sub Main(args As String())
Dim sourcePath As String = args(0)
Dim outputPath As String = args(1)
IO.Directory.CreateDirectory(outputPath)
@heckctor
heckctor / prepos_install.sh
Last active December 9, 2019 18:36
Script basico que descarga e instala Prepros Linux 5.10.2
#!/bin/bash
# -*- ENCODING: UTF-8 -*-
#Requiere de permisos de ejecución:$chmod -x prepros_install.sh
#Ejecutar como Root: $bash prepros_install.sh
#Validando Acceso Root
if [[ $EUID -ne 0 ]]; then
echo "Tienes que ejecutar este script como Root" 1>&2
exit 1
fi
@bashtoni
bashtoni / gist:cda204308d9730d6420e59d84f55f77e
Created July 4, 2018 10:49
Get HostedZoneId from AWS CLI for a given domain
aws route53 list-hosted-zones-by-name --dns-name example.com --query HostedZones[].Id --output text | cut -d/ -f3
@femmerling
femmerling / authenticate.py
Last active June 13, 2022 17:18
I have to create user authentication using python-ldap. After googling around and trying out stuffs, this is the final code for you to use. Please remember to adjust the user_dn, and base_dn accordingly to the format used in your LDAP server.
# to be able to import ldap run pip install python-ldap
import ldap
if __name__ == "__main__":
ldap_server="x.x.x.x"
username = "someuser"
password= "somepassword"
# the following is the user_dn format provided by the ldap server
user_dn = "uid="+username+",ou=someou,dc=somedc,dc=local"
@onyxraven
onyxraven / rds.sh
Last active June 21, 2022 13:42 — forked from douglasjarquin/gist:2208690
Amazon RDS Performance Tuning Settings
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB
#/32 = 496630545 = 473MB
#/64 = 248315272 = 236MB
#/128 = 124157636 = 118MB
#/256 = 62078818 = 59MB
#/512 = 31039409 = 29MB
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762
#/25165760 = 623 # half of max_connections = 1993.6MB
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608
#*(3/4) #default innodb pool size = 11922309120
@yumminhuang
yumminhuang / package_updates_check.py
Created March 18, 2015 20:39
Python script to check apt-get updates
#!/usr/bin/env python
#coding=utf-8
import apt
import apt_pkg
from time import strftime
import os
import subprocess
import sys