Skip to content

Instantly share code, notes, and snippets.

View josemarcosrf's full-sized avatar
🏔️
Working from a mountain top

Jose Marcos RF josemarcosrf

🏔️
Working from a mountain top
View GitHub Profile
@pavgup
pavgup / PrintPOSTandGET.py
Created April 23, 2014 15:47
This stands up a python http server and receives both POST and GET requests and prints to the console the parameters and values it receives over HTTP. This runs on port 9000 and binds 0.0.0.0, so be careful about firewall settings when testing this.
import BaseHTTPServer
import urlparse
class SimpleHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
if "?" in self.path:
for key,value in dict(urlparse.parse_qsl(self.path.split("?")[1], True)).items():
print key + " = " + value
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@dswah
dswah / layers_tied.py
Last active September 17, 2021 22:45
Tied Convolutional Weights with Keras for CNN Auto-encoders
from keras import backend as K
from keras import activations, initializations, regularizers, constraints
from keras.engine import Layer, InputSpec
from keras.utils.np_utils import conv_output_length
from keras.layers import Convolution1D, Convolution2D
import tensorflow as tf
class Convolution1D_tied(Layer):
'''Convolution operator for filtering neighborhoods of one-dimensional inputs.
When using this layer as the first layer in a model,
@alexlee-gk
alexlee-gk / configure_cuda_p70.md
Last active March 19, 2024 17:47
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@dusty-nv
dusty-nv / pytorch_jetson_install.sh
Last active October 21, 2021 01:28
Install procedure for pyTorch on NVIDIA Jetson TX1/TX2 with JetPack <= 3.2.1. For JetPack 4.2 and Xavier/Nano/TX2, see https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/
#!/bin/bash
#
# EDIT: this script is outdated, please see https://forums.developer.nvidia.com/t/pytorch-for-jetson-nano-version-1-6-0-now-available
#
sudo apt-get install python-pip
# upgrade pip
pip install -U pip
pip --version
# pip 9.0.1 from /home/ubuntu/.local/lib/python2.7/site-packages (python 2.7)
@justincbagley
justincbagley / How_to_Convert_Markdown_to_PDF.md
Last active April 28, 2024 22:28
How To Convert Markdown to PDF

How to convert markdown to PDF:

This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.

Using Pandoc:

$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf
@josemarcosrf
josemarcosrf / NaturalLanguageDatasets.md
Last active February 19, 2023 11:59
List of Language related open datasets. NLP NLU Dataset
@seb26
seb26 / A_one_line_formula.md
Last active January 3, 2024 19:50
This formula can be used in Google Sheets to take a value in bytes and then represent it in a human-readable format with binary units (KiB, MiB, GiB, and so on).
=ROUND( A2/(1024)^(FLOOR(log(A2)/log(1024))), 2) & " " & SWITCH( FLOOR( log(A2) / log(1024) ) ,0,"Bytes",1,"KiB",2,"MiB",3,"GiB",4,"TiB")
@felipou
felipou / decrypt_dbeaver.py
Last active May 14, 2024 22:14
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycryptodome lib (pip install pycryptodome)
import sys
import base64
import os
import json
from Crypto.Cipher import AES