In this article, I will share some of my experience on installing NVIDIA driver and CUDA on Linux OS. Here I mainly use Ubuntu as example. Comments for CentOS/Fedora are also provided as much as I can.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Node reverseAndClone(Node list) { | |
Node head = null; | |
while (list != null) { | |
Node n = new Node(list.val); | |
n.next = head; | |
head = n; | |
list = list.next; | |
} | |
return head; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This solution does not to store the whole link of nodes | |
* only the first half is needed to be stored so it is friendly | |
* for space complexity. It use fast runner and slow runner to | |
* find the middle point of the list of node. | |
* @param list | |
* @return | |
*/ | |
// Note: When I implemented this method I made two mistakes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <queue> | |
#include <stack> | |
#include <algorithm> | |
using namespace std; | |
class Node{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Download all the pdfs linked on a given webpage | |
Revised from the original author elssar's gist (https://gist.github.com/elssar/5160757) to scrap the pdf links in piazza resources | |
tab, the original script is for the websits don't need login. But you have | |
to login piazza to scape the contents. So I revised the request.post with | |
authentification info and turn the program to run with Python3 | |
Usage - | |
python grab_pdfs.py url <path/to/directory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index=1 | |
# ls -rt means list in the order of oldest first | |
for i in $(ls *.pdf -rt) | |
do | |
cp "${i}" "${index}_${i}" | |
index=$((index+1)) | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the solution by StefanPochmann https://leetcode.com/problems/swap-nodes-in-pairs/discuss/11019/7-8-lines-C++-Python-Ruby | |
ListNode* swapPairs(ListNode* head) { | |
ListNode **pp = &head, *a, *b; | |
while ((a = *pp) && (b = a->next)) { | |
a->next = b->next; | |
b->next = a; | |
*pp = b; | |
pp = &(a->next); | |
} | |
return head; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer