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
// g++ passing_by_example.cpp -o passing_by_example.x && ./passing_by_example.x | |
#include <iostream> | |
using namespace std; | |
int main(){ | |
int Bats = 1; | |
int *pB = &Bats; | |
int& rB = Bats; | |
void PassByValue(int b); |
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
// g++ dynamic_cast_example.cpp -o dynamic_cast_example.x && dynamic_cast_example.x | |
#include <iostream> | |
using namespace std; | |
class A { public: virtual string class_string() { return "Class A"; } }; | |
class B : public A { public: virtual string class_string() { return "Class B"; } }; | |
class C : public A { public: virtual string class_string() { return "Class C"; } }; | |
class D : public C { public: virtual string class_string() { return "Class D"; } }; | |
// dynamic_cast returns NULL if the cast is impossible and the type is a pointer |
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
/* | |
g++ -c -Wall -g chess_test.cpp && \ | |
g++ -g -o chess_test.exe chess_test.o &&\ | |
./chess_test.exe | |
*/ | |
#include <iostream> | |
#include <iomanip> | |
#include <list> | |
#include <vector> | |
using namespace std; |
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
/** To compile: | |
gcc -Wall -c named_func_params.c -o named_func_params.o && \ | |
gcc named_func_params.o -lm -o named_func_params.x && \ | |
named_func_params.x | |
*/ | |
#include<stdio.h> | |
typedef struct funcParams_s{ | |
int UID; | |
char uid_char[24]; |
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/perl -w | |
# AUTHOR: Stephen Meckley 7/10/2013 | |
package cnvrt; | |
use strict; | |
use warnings; | |
__PACKAGE__->main(@ARGV) unless caller; | |
sub main { |
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
function! RenameCurrentFile(newName) | |
let l:currentFile = expand("%:p") | |
silent! exe "saveas " . a:newName | |
if delete(l:currentFile) | |
echoerr "Could not delete " . l:currentFile | |
endif | |
endfunction | |
command! -nargs=1 -complete=file -bang RenameCurrentFile :call RenameCurrentFile("<args>") | |
noremap <Leader>rf :RenameCurrentFile <C-R>=expand("%:p")<CR> |
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
" | |
" You will have to restart vim for this to take effect. In any case | |
" it is a good idea to read ":he new-filetype" so that you know what | |
" is going on, and why the above lines work. | |
" | |
" Written originally by Dominic Mitchell, Jan 2006. | |
" happygiraffe.net | |
" | |
" Modified by Aaron Bieber, May 2007. | |
" blog.aaronbieber.com |
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: | |
if not session.counter: | |
session.counter = 1 | |
else: | |
session.counter += 1 | |
" Is equvalent to this: | |
session.counter = (session.counter or 0) + 1 |
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 recipe describes how to handle asynchronous I/O in an environment where | |
you are running Tkinter as the graphical user interface. Tkinter is safe | |
to use as long as all the graphics commands are handled in a single thread. | |
Since it is more efficient to make I/O channels to block and wait for something | |
to happen rather than poll at regular intervals, we want I/O to be handled | |
in separate threads. These can communicate in a threasafe way with the main, | |
GUI-oriented process through one or several queues. In this solution the GUI | |
still has to make a poll at a reasonable interval, to check if there is | |
something in the queue that needs processing. Other solutions are possible, |
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
# Interactively play with data in matplotlib!!! | |
# Start python command line: | |
# > python | |
# >>> | |
# Then copy and paste the code below. | |
import matplotlib.pyplot as plt | |
import matplotlib as mpl | |
import numpy as np |
OlderNewer