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
mysql --user=root --password=root --tee=./SQLSession.out | |
# To start the logging to the given file from the session use | |
# mysql> \T | |
# Logging to file ./SQLSession.out | |
# To stop logging use | |
# mysql> \t |
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
SELECT ROUND(numeric_value, -2) AS bucket, | |
COUNT(*) AS COUNT, | |
RPAD('', LOG(COUNT(*)), '*') AS bar | |
FROM my_table | |
GROUP BY bucket; | |
/* | |
numeric_value = column name | |
-2 to round in steps of 100. Use -1 for steps of 10 and any positive vale for rounding to nearest decimal | |
LOG(COUNT(*)) is to make the count on log scale |
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
""" | |
Using Monte Carlo to find the value of pi. | |
Intiution: Ratio of area of circle to area of uniq length squre it is inscribed it can be used to approximate pi. | |
Area of circle = pi/4 | |
Area of square = 1 | |
Ratio = pi/4 | |
Let us generate random points x,y inside the square. The probabilty of the point being inside circle is equal to the above ratio. | |
Circle centered on origin. | |
Given: -0.5 <= x,y <= 0.5 | |
A point is inside circle if x**2 + y**2 <= 1/4 |
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
max_n = 1200 | |
[k for k in range(1,max_n) if k % 10**int(np.log10(k)) == 0] | |
""" | |
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] | |
""" | |
#More computationally effective solution for large max_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
""" | |
This code snippet explains the implementation of a dictionary using a hashing function. | |
Problem: Store the marks of student with given roll numbers in a data structure for quick access of marks based on roll number. | |
Concept: Use a dictionary data structure. | |
""" | |
roll_numbers = [9,8,7,2,1,3,4,5] | |
marks = [10,20,5,13,77,33,2,99] | |
HASH_CONST=11 # Constant used for hashing. For practical purposes more sophesticated and optimized hash functions are used. |
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
# coding=UTF-8 | |
import nltk | |
from nltk.corpus import brown | |
# This is a fast and simple noun phrase extractor (based on NLTK) | |
# Feel free to use it, just keep a link back to this post | |
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/ | |
# Create by Shlomi Babluki | |
# May, 2013 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* | |
* @author napsternxg | |
*/ |
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 returnFirstPostImage($id){ | |
global $wpdb; | |
$the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id"); | |
$pattern = '!<img.*?src="(.*?)"!'; | |
preg_match_all($pattern, $the_content, $matches); | |
$image_src = $matches['1'][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
('----- diversity:', 0.2) | |
----- Generating with seed: " cane | |
the train's wh" | |
cane | |
the train's wh bcattat saobnahhsaaelmemm t ealaeeteueuiirrrrethu uriibiboboo tat stttalalllaer tmettummm p ooor rthhuie rrres aa | |
('----- diversity:', 0.5) | |
----- Generating with seed: " cane | |
the train's wh" | |
cane |
OlderNewer