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 for sorting an array of objects by their properties. | |
* Based off this stackoverflow post: http://stackoverflow.com/questions/1129216/sorting-objects-in-an-array-by-a-field-value-in-javascript/4760279#4760279 | |
* | |
* Example: | |
* var People = [ | |
* {Name: "Name", Surname: "Surname"}, | |
* {Name:"AAA", Surname:"ZZZ"}, | |
* {Name: "Name", Surname: "AAA"} | |
* ]; |
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
/** | |
* Pass a function to fn along with an optional callback | |
*/ | |
function async(fn, callback) { | |
setTimeout(function() { | |
fn(); | |
if (typeof callback !== "undefined") | |
callback(); | |
}, 0); |
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
// Returns true if bootstrap is loaded, false otherwise | |
// Checks for Bootstra 2 or 3 | |
// Based off this post: http://stackoverflow.com/questions/13933000/how-to-check-if-twitter-bootstrap-is-loaded | |
function bootstrapIsEnabled(){ | |
return (typeof $().modal == 'function'); | |
}; |
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
# [oldpassword] is the password used for the old database and [newpassword] is the one for the destination database | |
# there is also no space between the -p and [old/newpassword] | |
$ mysqldump -h oldhost -u oldusername -p[oldpassword] olddbname | mysql -h newhost -u newusername -p[newpassword] newdbname | |
# This command can also be spilt into 2 ones if you want to perform them one at a time by saving the data into a temporary file | |
$ mysqldump -h oldhost -u oldusername -p[oldpassword] olddbname > temp.sql | |
$ cat temp.sql | mysql -h newhost -u newusername -p[newpassword] newdbname | |
# Delete the temp.sql with `rm temp.sql` | |
# If done the second way, you can also choose not to include the password when typing the command and instead type it later |
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
# Taken from https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks | |
# Remove MySQL | |
$ ps -ax | grep mysql # stop and kill any MySQL processes | |
$ brew remove mysql | |
$ sudo rm /usr/local/mysql | |
$ sudo rm -rf /usr/local/var/mysql | |
$ sudo rm -rf /usr/local/mysql* | |
# Install MySQL |
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
print list(set(map(int, raw_input().split()))) # takes a string of ints and returns the list with duplicates removed |
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
clear all; close all; clc; | |
W = 4; | |
Fs = 100; % large frequency to replicate continuous data (dt) | |
t = 0:1/Fs:W-1/Fs; | |
N = length(t); | |
x = cos(2*pi*t); | |
% Fourier transform | |
f = -10:1/Fs:10; |
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
clear all; close all; clc; | |
W = 5; | |
fs = 100; | |
t = -W:1/fs:W; | |
N = length(t); | |
x = cos(2*pi*t); | |
% Fourier transform | |
bin_inc = fs/N; |
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
clear all; close all; clc; | |
W = 2; | |
Fs = 100; % frequency meant to replicate continuous data | |
t = 0:1/Fs:W-1/Fs; | |
N = length(t); | |
x = cos(2*pi*t); | |
% Sampled x | |
fs = 20; % sampling frequency |
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 <stdlib.h> | |
int main(){ | |
int ret = system("rm backup.c a.out"); | |
return 0; | |
} |
OlderNewer