Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl -w
######################################################################
# skip_lines.pl -- skips selected lines of a given file
#
# perl skip_lines.pl /path/to/file.txt 1,3,4,5
# | | |
# script -----+ | |
# text file ---------------+ |
# comma separated line numbers ---------+
# with no spaces
<!DOCTYPE html>
<html>
<head>
<title>Weather Widget 1</title>
<script>
function getUrl() {
return "http://localhost:8080/scratch/weather.xml";
}
@andreburto
andreburto / clock.html
Last active August 23, 2020 23:19
Basic clock display
<!DOCTYPE html>
<html>
<head>
<title>Clock Widget 3</title>
<script>
var hour = 0;
var min = 0;
var sec = 0;
var year = 0;
var month = 0
<!DOCTYPE html>
<html>
<head>
<title>Polyglot</title>
<hta:application applicationname="Polyglot" scroll="no" singleinstance="no" />
<script type="text/vbscript">
Sub Window_onLoad
window.resizeTo 250,250
End Sub
function main{
Add-Type -AssemblyName presentationframework
$html = [string]@"
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
<script>
# Query Yahoo!Weather to get the results. More can be gleaned than just the forecast.
function getWeather([string]$city, [string]$state){
$query = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='{0}, {1}')"
$url = "https://query.yahooapis.com/v1/public/yql?q={0}&format=xml&env=store://datatables.org/alltableswithkeys"
$newQuery = $query -f $city, $state
$newUrl = $url -f $newQuery
[xml]$data = Invoke-RestMethod -Uri $newUrl
function main{
Add-Type -AssemblyName presentationframework
$xaml = [xml]@"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
@andreburto
andreburto / plate_ratio.py
Last active October 22, 2017 00:00
Calculate the ratio from System bricks/plates to Technic holes.
from __future__ import print_function
from sys import exit
from math import floor
from nose.tools import assert_equals
__author__ = "Andy Burton"
PLATES_IN_BRICK = 3
@andreburto
andreburto / admin-login.py
Last active August 11, 2017 02:04
Quickly login to the Django Admin screen
# Python standard library
import os
import getpass
from urlparse import urlparse
# Third-party libraries
import requests
from bs4 import BeautifulSoup
__author__ = 'Andy Burton'
@andreburto
andreburto / annicount.py
Last active June 11, 2017 13:03
Count the leap years since a couple was married.
import datetime, calendar
def find_leap_years_in_marriage(married_year):
current_year = datetime.datetime.now().year
return sum([1 for year in range(married_year, current_year) if calendar.isleap(year)])
if __name__ == '__main__':
import sys
leap_year_count = find_leap_years_in_marriage(int(sys.argv[1]))
print 'You have {yc} leap years between when you were married and this anniversary.'.format(yc=leap_year_count)