This is a collection of my most often used lines of code, as well as a few other examples I want to have ready at a moment's notice. These snippets focus on building HTML from scratch, linking in good web fonts, and setting up responsive styles for your pages.
| [Unit] | |
| Description="frappe-bench-frappe-default-worker" | |
| PartOf=frappe-bench-workers.target | |
| [Service] | |
| User=revant | |
| Group=revant | |
| Restart=always | |
| ExecStart=/home/revant/.local/bin/bench worker --queue default | |
| StandardOutput=file:/home/revant/frappe-bench/logs/worker.log |
| import os | |
| import platform | |
| if os.name == 'nt' and platform.release() == '10' and platform.version() >= '10.0.14393': | |
| # Fix ANSI color in Windows 10 version 10.0.14393 (Windows Anniversary Update) | |
| import ctypes | |
| kernel32 = ctypes.windll.kernel32 | |
| kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) |
| # Helper function to plot a decision boundary. | |
| # If you don't fully understand this function don't worry, it just generates the contour plot below. | |
| def plot_decision_boundary(pred_func): | |
| # Set min and max values and give it some padding | |
| x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5 | |
| y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5 | |
| h = 0.01 | |
| # Generate a grid of points with distance h between them | |
| xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h)) | |
| # Predict the function value for the whole gid |
| #!/usr/bin/env python | |
| """Compare two aligned images of the same size. | |
| Usage: python compare.py first-image second-image | |
| """ | |
| import sys | |
| from scipy.misc import imread | |
| from scipy.linalg import norm |
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| import tweepy #https://github.com/tweepy/tweepy | |
| import csv | |
| import sys | |
| #Twitter API credentials | |
| consumer_key = "" | |
| consumer_secret = "" |
| // convert 0..255 R,G,B values to binary string | |
| RGBToBin = function(r,g,b){ | |
| var bin = r << 16 | g << 8 | b; | |
| return (function(h){ | |
| return new Array(25-h.length).join("0")+h | |
| })(bin.toString(2)) | |
| } | |
| // convert 0..255 R,G,B values to a hexidecimal color string | |
| RGBToHex = function(r,g,b){ |
| var redis = require("redis") | |
| , subscriber = redis.createClient() | |
| , publisher = redis.createClient(); | |
| subscriber.on("message", function(channel, message) { | |
| console.log("Message '" + message + "' on channel '" + channel + "' arrived!") | |
| }); | |
| subscriber.subscribe("test"); |
RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.
Set an OnClickListener in your ViewHolder creation:
private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
public static class ViewHolder extends RecyclerView.ViewHolderUbuntu 15.10 have been released for a couple of days. It is a bleeding-edge system coming with Linux kernel 4.2 and GCC 5. However, compiling and running Caffe on this new system is no longer as smooth as on earlier versions. I have done some research related to this issue and finally find a way out. I summarize it here in this short tutorial and I hope more people and enjoy this new system without breaking their works.
The latest NVIDIA driver is officially included in Ubuntu 15.10 repositories. One can install it directly via apt-get.
sudo apt-get install nvidia-352-updates nvidia-modprobe
The nvidia-modprobe utility is used to load NVIDIA kernel modules and create NVIDIA character device files automatically everytime your machine boots up.
Reboot your machine and verify everything works by issuing nvidia-smi or running deviceQuery in CUDA samples.