This file contains hidden or 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
# http://lite.ip2location.com/ | |
# http://stackoverflow.com/questions/3650006/get-country-of-ip-address-with-php | |
# IP Number = 16777216*w + 65536*x + 256*y + z | |
# where IP Address = w.x.y.z | |
# | |
# To reverse IP number to IP address, | |
# w = int ( IP Number / 16777216 ) % 256 | |
# x = int ( IP Number / 65536 ) % 256 | |
# y = int ( IP Number / 256 ) % 256 |
This file contains hidden or 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
''' https://developers.google.com/resources/api-libraries/documentation/youtube/v3/csharp/latest/classGoogle_1_1Apis_1_1YouTube_1_1v3_1_1Data_1_1VideoContentDetails.html#a0527b84283db20cf2ef8f3de22f65606 | |
Dim ts As TimeSpan = System.Xml.XmlConvert.ToTimeSpan(vid.ContentDetails.Duration) | |
Me.Length = ts.TotalSeconds() |
This file contains hidden or 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
@echo off | |
echo Build date %DATE% | |
REM Write to file: BuildDate.vb | |
echo ' This file is autogenerated by CreateBuildDate.bat. Changes here will be lost. > BuildDate.vb | |
echo Namespace Snuffbox.Configuration >> BuildDate.vb | |
echo Public Partial Class Settings >> BuildDate.vb | |
echo Public Shared ReadOnly Property BuildDate As String >> BuildDate.vb | |
echo Get >> BuildDate.vb | |
echo Return "%DATE% %TIME:~0,8%" >> BuildDate.vb |
This file contains hidden or 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
# Visa det billigaste bensinpriset i Göteborg, via bensinpriser.se. | |
import requests # pip install requests | |
from bs4 import BeautifulSoup # pip install BeautifulSoup4 | |
r = requests.get('http://www.bensinpriser.se/v%C3%A4stra-g%C3%B6talands-l%C3%A4n/g%C3%B6teborg/g%C3%B6teborg') | |
soup = BeautifulSoup(r.text, "lxml") # pip install lxml | |
rowIndex = 0 | |
for row in soup.select(".resulttable tr"): | |
rowIndex = rowIndex + 1 |
This file contains hidden or 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
-- Group by database (MB). | |
SELECT table_schema 'Database Name', | |
SUM(data_length + index_length ) / 1048576 'Database Size (MB)', | |
SUM(data_free) / 1048576 'Free Space (MB)' | |
FROM information_schema.TABLES | |
GROUP BY table_schema; | |
-- Group by database and table (bytes). | |
SELECT table_schema 'databasename', | |
table_name 'tablename', |
This file contains hidden or 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
ip <- as.data.frame(installed.packages()[,c(1,3:4)]) | |
rownames(ip) <- NULL | |
ip <- ip[is.na(ip$Priority),1:2,drop=FALSE] | |
print(ip, row.names=FALSE) | |
# From http://www.r-bloggers.com/list-of-user-installed-r-packages-and-their-versions/ |
This file contains hidden or 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
library(rvest) # install.packages("rvest") | |
library(plyr) # install.packages("plyr") | |
# Get html from url: Sveriges riksdagsledamöter 2014-2018. | |
riksdag.html <- html("https://sv.wikipedia.org/wiki/Lista_%C3%B6ver_ledam%C3%B6ter_av_Sveriges_riksdag_2014%E2%80%932018", encoding = "UTF8") | |
# Import table from html. | |
riksdag.tables <- html_table(riksdag.html, fill=TRUE, trim=TRUE) | |
riksdag.df <- riksdag.tables[[1]] |
This file contains hidden or 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 --database=dbname -B -N -e "SHOW TABLES" \ | |
| awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' \ | |
| mysql --database=dbname & | |
# http://stackoverflow.com/questions/105572/a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql |
This file contains hidden or 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/python | |
# Delete all lines in file A (keep.txt) that are present in file B (delete.txt). | |
# Rules: | |
# 1. If line is found in B but not in A, then delete (i.e., do not merge files). | |
# 2. If line is found in B and in A too, then delete (i.e., delete duplicates). | |
# Read file with lines that we shall keep. | |
keepfile = open("keep.txt") | |
keeplines = keepfile.readlines() |
This file contains hidden or 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
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) | |
# http://stackoverflow.com/questions/5059692/unable-to-update-r-packages-in-default-library-on-windows-7 |
OlderNewer