Skip to content

Instantly share code, notes, and snippets.

@andrewjong
andrewjong / pytorch_image_folder_with_file_paths.py
Last active February 27, 2024 09:24
PyTorch Image File Paths With Dataset Dataloader
import torch
from torchvision import datasets
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
torchvision.datasets.ImageFolder
"""
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(self, index):
@kylemcdonald
kylemcdonald / matplotlib Border Removal.ipynb
Last active January 29, 2024 18:35
How to (mostly) remove all borders and padding with matplotlib.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@samrocketman
samrocketman / libimobiledevice_ifuse_Ubuntu.md
Last active January 11, 2024 22:47
On Ubuntu 16.04, since iOS 10 update, libimobiledevice can't connect to my iPhone. This is my attempt to document a fix.

Why this document?

I upgraded my iPhone 5s to iOS 10 and could no longer retrieve photos from it. This was unacceptable for me so I worked at achieving retrieving my photos. This document is my story (on Ubuntu 16.04).

The solution is to compile libimobiledevice and ifuse from source.

Audience

Who is this guide intended for?

@52cik
52cik / npm.taobao.sh
Last active February 29, 2024 02:56
npm 淘宝镜像配置
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set ELECTRON_MIRROR https://cdn.npm.taobao.org/dist/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
@ibogun
ibogun / gist:ec0a4005c25df57a1b9d
Last active February 2, 2021 13:26
Installing gcc 4.9 & g++ 4.9 on Ubuntu 12.04 OR Ubuntu 14.04
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo apt-get install g++-4.9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
@polbins
polbins / README.md
Last active February 29, 2024 09:58
Simple RecyclerView Divider

Simple RecyclerView Divider

Simple Horizontal Divider Item Decoration for RecyclerView

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(
            getApplicationContext()
    	));

NOTE: Add item decoration prior to setting the adapter

@romanlarionov
romanlarionov / BeginningOpenGl.md
Last active June 5, 2023 07:29
OpenGL Startup

Travel Guide to OpenGL

I've figured out several things while trying to extend my knowledge of Computer Graphics.

  1. OpenGL can be a bitch if you don't know what you're doing.
  2. There is no worse pain than to experience CMake without knowing what you're doing.
  3. When walking to the depths of hell, it would be nice to have a travel guide.

And that's what this is, a travel guide.

@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@rduplain
rduplain / app.py
Created May 20, 2012 16:45
Add a second static directory to Flask, in ../static/.
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/base/<path:filename>')
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)