2024
Fix windows 5 second freeze every 10-15 minutes
I’ve been typing on a nice laptop for about a year and a half, then lately it’s been freezing, making it very annoying. I’ve been watching Task Manager, then clicking on the lower left to Resource Monitor, then lately escalated to the Sysinternals Process Explorer
Pandas Indexing Primer
2023
SQLite and Pandas quick intro
Want to setup a techie blog simply?
Author name wrong in Git repo?
The Author name is wrong, or we need to change it, fast. To fix the Author Name etc on all commits in a github repo, an easy way is
git is tricky - be trickier like a fugitive = vim + git
Git is one of the most widely used tools of the modern programmer, and vim is one of the classic editors. Programmers choose git and vim because they each give tremendous value in working with files, including both data and source code.
Select is switch/case for concurrency!
Go versus C declarations
Goroutines and channels - simple!
wwhhhaattt vim 4 panel git merge???
change Author name & email across all commits in github repo
To change the Author Name etc on all commits in a github repo, an easy way is
Need a decently priced rum?
Hamilton 86 is Guyanese rum without added sugar. Sipping, it opens a clean, straight slight burn, smooth, then we find the caramel, tobacco, smoke, really a nice rum and well priced.
2020
Modular Programming - Chapters 4-6
- Chapter 4 - Using Modules for Real-World Programming
- There’s an example which shows the modular approach helps when requirements change. Though the example is long, it is also instructive. Changing requirements is one of the primary software challenges.
- There’s code but there was a problem with fonts - so some of the example code didn’t run.
- Chapter 5 - Working with Module Patterns
- Encapsulation
- Encapsulation is the idea that you hide information about “things” that a program is concerned with in objects using e.g. get/set methods. Although this is a widespread practice, it is also not obviously a good one in many cases, for example
- Wrappers
- A simple example involving banks doesn’t show us the value of having wrapped the some functions from numpy, because they are themselves somewhat simple. It would be more instructive to wrap a complex abstraction into a simpler one.
- Extensible modules
- Introduces dynamic imports which allow original code to be written so it can be extended with modules that may be written in the future but are not available at the time the original code was being written.
- He gives a simple but very powerful example calling importlib with a string formatted according to the chart format and output. Plugins and hooks are a similar concept. This example is worth studying.
- Encapsulation
- Chapter 6 Creating Reusable Modules
- Another nice example program that converts e.g. distance, volume etc. units - long example so better if you clone the book’s code from github.
- The code in the book works, but if you try variations e.g. gallons to liters or add and subtract, per the test file comments, it doesn’t work (at least right off the bat). Even so might be a good case to try to fix or debug or perhaps works slightly different from book examples.
Modular Programming with Python - review of first 3 chapters
Review Post - Modular Python by Erik Westra, Chapters 1-3
While loops: 5 things to know
Number 1: what is a while loop:
Predicting based on timeseries
- Suppose we have a dataset of phone pickups and timestamps, and we want to know if the chance of pickup varies with time. A question on the Internet asks whether to use linear regression, and whether 1-hot encoding would be useful.
- Linear regression finds the best fit line between the input and the target variable. It works when the target is proportional to the input. But the probability of picking up a phone call is not proportional to the hour of day on a 24 hour basis - 8am might have high rate, 9am not, and 12 again have a high rate.
- We can think about 1-hot encoding. We have timestamps and 0/1 for pickup or no pickup. If we 1-hot encode the hour, we’ll get 24 independent variables that take on values of 0 or 1 . For the regression problem we’ll be fitting 24 coefficients for these 24 variables to predict call pickup. Each coefficient could be interpreted as the probability of pickup during the corresponding hour. Time is the independent variable, the 1-hot encoding represents the hour of that timestamp, and the prediction of the regression is just the probability of pickup based on the dataset.
- To find out if this is a good approach, we need to think about what we’re trying to do - the objective. If the objective is to know whether the probability of pickup varies over the hours, then the variation in the coefficients tells us how the hour predicts the probability of pickup.
- But using linear regression here is overly complex - we get the same result by grouping your data by hour and then finding the fraction of pickups over total calls.
2017
screensaver
found a nice screen blurring command that relies on ImageMagick
volume from mint command line
pactl set-sink-volume 0 +15%
Excel: unmerge when unmerge is greyed 0ut using format paintbrush
one thing that may work is to use the format paintbrush to brush in from an unmerged cell
2016
Outlook locks up, “Research Pane”
Once every couple of weeks, my Outlook 2010 freezes up. Whatever I click, I get “Research Pane,” and nothing I type shows up. I wondered if it was a keyboard issue, but other MS applications worked. So after some Googling I found a solution. Need to open VB (Alt-F11) and then the immediate window (Ctrl-G), and then type:
Useful git aliases
Here’s some useful git configurations and aliases. The way you make a git alias is as follows:
PIXMA 100 setup
this is a cheap and apparently old printer. Important points:
2015
no sound on ipad games
check rotation lock, it is the same switch for mute, which can stop game sounds
hotas joystick
pressing mapping&preset together, then the home light will flash. then reboot. you can test whether the driver is working from settings
2013
wireless on debian toshiba satellite
- lspci, look for wireless network
- the drivers are proprietary, non-free so google for the driver and install. in this case it was firmware-iwlwifi.
- wireless-tools
- wicd (networkmanager also may have been helpful at some time, but i think its best to have only 1 of them installed.)
- reboot and check the hardware wireless switch is on. (removed something called avahi-auto ipd because i wasnt getting connection and i thought it was interfering, turned out to be the wireless switch, doesn’t seem to have messed anything up either way and i don’t know what it does.)
wipe failing drive using systemrescuecd
ddrescue --force /dev/zero /dev/sdb log.txt
fill out and sign a PDF on debian
- fill out form with xournal and export pdf. (oowriter didn’t read xournal’s output even with the libreoffice pdf import extension, but the xournal’d pdf did print, gimp was able to read it, and it was emailable)
- edit a photo of signature in gimp (nice video http://youtu.be/efAOsvfi4sU)
- layer/transparency/add alpha channel. like writing on an overhead slide, the checkerboard represents the background through the slide
- use fuzzy select tool from toolbox to select the background from the photo
- delete the background, should see checkerboard. delete within loops for O, Q, etc.
- from brushes, select the largest black brush and set mode to overlay. brush over the signature to darken it to a uniform black, otherwise it looks grayish like a photo when printed.
- open the pdf from gimp and select the page which needs the signature
- use the rectangle select tool to select the area where the signature should go. note the height and/or width of the field.
- go to the signature image and image/scale image. enter either the height or width to scale to, then`edit/copy visible.
- go back to the pdf and right click on the rectangle and paste.
- export the page to pdf
- use pdfshuffler to replace the unsigned page with the signed page in the PDF in order. may need pdfshuffler orig sign orig (wasn’t able to move later pages to earlier ones, but was able to delete pages).
adding wireless epson workforce 633 printer
- add yourself to the lpadmin group using
sudo usermod -a -G lpadmin tom /etc/init.d/cups restart
- printer should see router so connect them and get the confirmation printout which has the IP
- go to http://localhost:631/
- add printer, give 1 word for printer name. URL will be socket://IP from printout. cups already has the driver, add Epson Workforce 630
- lp -d printername whatever.pdf
- debian wiki on printing
- cups printing documentation
2012
LaTeX formulas in xfig
To add LaTeX formulas to xfig
latex -> text
$ catdvi -e 1 -U file.dvi | sed -re “s/\[U\+2022\]/*/g” | sed -re “s/([^^[:space:]])\s+/\1 /g” > file.txt |
google voice, failed to retrieve and set forwarding
got a new phone, installed the voice app but google voicemail not working. found out the thing to do is:
copy audio cd
mkdir wavdir cdparanoia -B cdrecord -v -audio *.wav
copying hardlinked backups
have 2 external drives, and i use backintime to backup my main hd to one of these drives. now i want to copy the 1st external usb drive to the 2nd, but backintime uses hardlinks, and i need to preserve these. rsync can do it, but evidently takes a long time, so easier to use
mplayer mpeg stream reached EOF
make sure mariallat debian source is there, then install libdvdcss2
inflating bike tire when the stem wants to unscrew with the adaptor
- unscrew the little stem valve, it will remain on a small metal stick
- screw the adaptor onto the stem
- with the lever down, place the pump head onto the adaptor
- raise the lever
- pump air
- lower the lever again and remove the pump head
- unscrew the adaptor.
- if necessary, as the adaptor clears the threads so you can see the small stem, then grab the stem with needlenose pliers as soon as possible, then continue unscrewing the adaptor
- then rescrew the stem down quickly
2011
mount windows share
This worked on Debian to mount a windows share.
sudoers nopasswd
how do you get it to stop asking for the password for me on my single-user laptop? the sudoers manpage was written by someone who was very fascinated by grammar and not by clear explanation. but this seems to be working:
i3 container
using the very nice i3 window manager and asked something today on the irc channel, found that you can have container moving by copying /etc/X11/i3/config to ~/.i3/config and changing the lines so that
debian-multimedia GPG error
well I’ll see if this fixes the error that’s been breaking my nightly cron-apt.
installed debian packages sorted by size
aptitude search ~i -O installsize -F”%p %I”
2010
wicd-client –no-tray for ion3
i use ion3 as my window manager, and it doesn’t have a tray, and wicd-client assumes you have a tray… couldn’t get wireless working until i saw a post somewhere where someone mentioned you could do
Don’t do anything when closing lid
I have a 17” desktop-replacement type laptop which I’d like to be able to close from time to time and use the lid as a writing surface. But when I close the lid, I don’t want any kind of suspend etc since I have a separate monitor and keyboard so I can still use the machine while the lid is closed. So far what worked was to edit /etc/acpi/lid.sh and put in “exit 0” at the top, which prevents acpi from doing anything at all when a lid event occurs. I can see the lid events in /etc/acpi/events/lidbtn seem to just execute /etc/acpi/lid.sh so i think this might continue to work for a while.
How to keep less from clearing the screen
I was finally getting desperate with R’s history() command clearing my screen after showing me my history, totally useless. After some puttering around, i found that history() just ends up calling $PAGER, which for me was less. Typing h into history() confirmed that I was looking at less. So then googling how to get rid of less’s behaviour turned up this page:
PasswordMaker and FoxFilter
To make PWM not enter a password into the “Allow website” form from FoxFilter, you
Bye bye flash, hello gnash
This afternoon I was finding my computer really bogged down. I was averaging 1.5 loads or so. After a bit of poking, I found the culprit (again), xulrunner. Killed it, was thinking Firefox was junk. Tried out midori and epiphany, they’re nice, but I can’t survive without vimperator anymore. Sad but true.
smbclient, beamer, and pgfpages
Today’s problem is that I need to print slides for a poster session that I’m going to. I’ve never printed to the color printer, so I don’t know the share name. Simple:
ALSA and Flash
I’ve long wanted to do this, and I don’t know how it was so simple all along. I have 2 external USB DACs, which go to 2 amps for 2 rooms. there’s also the multichannel audio on the Dell 9300 itself, and for a while I was trying to get Skype working (I’ve given up, though it would be nice to run off of Linux it just doesn’t work reliably enough so I’ve gotten the Belkin Desktop Internet Phone which is working out rather nicely for now.
beeps
i hate beeps of all kinds. the new install was beeping when gdm started, then it was beeping for no reason when i hit capslock in the empty space, when man pages over the beginning or end of a manpage, etc. i needed this fixed. found a few things on the internet, but i feel my solution so far is incomplete:
wicd vs NetworkManager
spent the better part of an hour wrestling with wicd to try to get it to connect to my linksys WPA2. but it kept saying “incorrect password” even though i could see both passwords and i could see they were the same. tried password versus preshared key, no luck. pulling my hair out, then i had the thought to try nm-applet. it saw the networks, and then it said it connected, though i couldn’t ping google – immediately did a aptitude purge wicd and rebooted, ran nm-applet and voila, here i am posting over WPA2. something is wrong with wicd.
smbclient
I run on a Debian machine, and I’m in a Windows environment. So from time to time I have to map some share on a machine and upload or download some file. Every time I panic because I don’t remember how to do this smbclient stuff, so I’m just going to post it here. First, I have a file called authfile, which has in it 3 lines: [sourcecode] username = myusername password = mypassword domain = thedomain [/sourcecode]
irssi, skype, pulseaudio, and wacom on vista
did a few things today. found irssi again, for some reason it wasn’t in aptitude for a while. now it is. great, i can ask questions on irc.debian.org again. by the way i tried logging into that and irssi was failing ,and i found it was about clearing the hostname. googleable whatever it was.
cryptsetup and quickfix
2 unrelated things which I fixed up today. First, a few days ago my Fujitsu P7320, which I am very fond of, had its HD fail. So it’s off being repaired, presumably returning with a fresh HD. I used it often to transfer files between my various machines using git - although git is a dvcs, i was also using it to sync machines, leading to lots of illogical commits, which I’m sure some purist would say is appalling, but it works and works fast, and so far I haven’t had trouble. But now that the Fujitsu is out, I needed to use a thumbdrive. Last time I used one for syncing, i lost it for some time, then weeks later found when the snow in my driveway melted. (Amazingly, it still worked.) But while it was lost I was always worried about whether there were any important passwords cc’s etc on the drive. I determined to never use an unencrypted thumbdrive again. So today I had to get it encrypted in a hurry, and I found the relevant commands and they were simple, so here they are: [sourcecode lang=”bash”] cryptsetup luksFormat /dev/sdX cryptsetup luksOpen /dev/sdX thumbdrive # enter password mkfs.ext2 /dev/mapper/thumbdrive mount /dev/mapper/thumbdrive /media/thumbdrive # do whatever [/sourcecode]
Skype 2.1.0.81 on Debian Squeeze/sid
Finally got it working. It worked a long time ago under 1.0.0.something, then debian updated and it broke for years. I don’t have time to work it out, then a few days ago I lost my cellphone and so I needed to figure it out. A few google searches and I found a thread on skype where people had the identical problems to mine. Eventually many of them fixed it by mucking with the Options/Sound Preferences and choosing cards. Here’s the thread.
2009
Wireless on Fujitsu Lifebook P7230 under Debian Squeeze
Finally got wireless working on the Fujitsu Lifebook P 7230 under Debian squeeze (testing).
Firefox Instability Fix
I’ve been having fun with vimperator, but then my firefox on one of my (Debian) laptops became unstable. I’d rightclick on a field, and it would crash. I ran it from the commandline to see if there’s any error messages, it would just say Segmentation fault. I didn’t have time to get a tracer and see where it’s crashing, and I did need to to work again quickly. I tried aptitude reinstall firefox, but that doesn’t seem to do anything useful, since it reinstalls the same binary and it was still crashing; the problem wasn’t in the binary or system-wide configuration (which I didn’t touch). Then I had some intelligent instincts; I already guessed that the problem wasn’t there, and so it had to be in my add-ons, like vimperator. But I didn’t know which one. I’ve always tried to keep the number of addons that I use down; and the answer was simply
vimperator and Outlook Web Access Light
So one feature of vimperator which has made it indispensable to me is Ctrl-I on a web form textbox. When vimperator receives Ctrl-I, it opens a gvim instance on the textbox, you can edit in gvim, and then vimperator puts your result back into the textbox. Amazingly useful; it’s let me write better emails than I did when I was just typing into a textbox and trying to send off the email without any editing ability. Some websites use Flash or some other kind of textboxes though (such as Google Docs), but now I deal with them manually by opening gvim myself and pasting a tmpfile because I’m so used to the advantage of having gvim on textboxes.
delicious and vimperator
I’ve been trying to figure out how to use delicious with vimperator. I installed the delicious vimperator plugin and now I have the :delicious command, which doesn’t seem to do anything as far as I can tell. I asked a couple of times on the freenode/#vimperator channel, which is very nice, but nobody seemed to know.
bash scripts for using git to sync laptops
I have 3 Debian laptops which I use daily. One at home, one at school, and one which I carry in my backpack. I’m also a backup nut. I have 4 external drives totaling 3.25T of storage which are for storing and backing each other up. For years I used rsync with linked files, which was alright but always had issues – sometimes the links wouldn’t propagate back properly for no apparent reason. I’d have the impression that things were working well when … really there was just the latest snapshot available.
How the python logger works in a few simple examples
this had also been a mystery to me. the python docs on the logger were pretty unintelligible, and i’ve used print statements for years, and i could see that the python logger seemed to be doing something, its just i couldn’t figure out what. so now the mystery is partially resolved. i think some examples might be the best way to learn about it. they added examples to the latest python docs which helped me alot, but i think some more might be useful.
wordpress charges for custom css
so i discovered this when i posted some python code to my other blog, and it came out too small. i found a blog with nicer code on it, and figured it must be the css, which i viewed and found what to do, it was to add
bash completion for vim and latex
I want bash to complete .tex whenever I type vim file. and there’s a file.tex in the directory. This was driving me nuts since it was completing all the LaTeX aux files etc whenever I did it, but I found (again) /etc/bash_completion which has the line
Beginning learning MapleTA
MapleTA has been something I’ve been meaning to learn for some time now. I use MapleTA that others have written in my classes, but I want to learn it so I can write my own questions. But it’s been problematic since I’ve never seen any language reference or user guide or anything, so I looked briefly at questionbank source code of others but couldn’t find the motivation to really figure it out. Finally the other day I found a user guide. I read it yesterday on the train, and found some examples which I’m typing in and running. That’s good, but I must say the user guide could really use a bit of work by a professional technical writer. It’s usable, but it could be a lot better, and that would really open up MapleTA to a lot of people. They made it very GUI-based, but it’s not at all stand-alone, you do need to read the user guide. I also don’t know Maple itself, so I have to learn that. (I know Mathematica, I wonder if there’s a MathematicaTA, but in any case we’ve adopted MapleTA.) I found that I really only need to start in Chapter 7.
Get rid of black lines and grey backgrounds under LaTeX2html formulas
This was a problem for some time. Whenever I had an inline formula $x^2$ for example, there’d be an ugly, distracting line under it in LaTeX2html. Found the fix today, at this Wiki site at Drexel. Copying out the relevant portion for future use:
a simple cron file is better than cron-apt
ive been trying to get cron-apt to download and install packages. i was able to get it to update and download, but never to install, and i dont want to know how to do it anymore. really all you need to do is put an executable file in /etc/cron.daily/cronaptitude with
daylight savings time on dualboot debian
been having some trouble with time on a dualboot debian laptop. i tried