Remove Unwanted Files From Git History

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

Here’s an example of how to remove every *.pyc file from every commit in Git history. It is adapted from this Git help page.

Rewrite history

Run git filter-branch, forcing (--force) Git to process—but not check out (--index-filter)—the entire history of every branch and tag (--tag-name-filter cat -- --all), removing the specified files ('git rm --cached --ignore-unmatch *.pyc') and any empty commits generated as a result (--prune-empty). Continue reading

Adding Git version control to web sites

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

Here’s a little script I made to make it easy to put a number of existing web sites residing under /var/www under version control by Git. Regarding security, it is obviously not a good idea to initialize the Git repository directly under the site directory, since from there it might be served by the web server to the outside world. And that is not what I want. Instead what I want is to have the Git working directory directly in the site directory that is served, and the repository somewhere else. That is perfectly possible with Git, just by setting one or two environment variables. Continue reading

Upsert Methods for PostgreSQL

  • 3.00 / 5 5
2 votes, 3.00 avg. rating (69% score)

PostgreSQL has no “upsert” or “replace” or “insert .. on duplicate key update” or “merge into” construct to conditionally either insert a new row, or if a row with the key already exists, to either update the existing row with the new values, or first delete the old row and then insert a new one. This has been discussed many times in the posgresql developers mailing lists, and plans to implement the SQL standard MERGE operation have been devised. But there is still no such functionalily in PostgreSQL as of version 9.3. Here are some examples on how to implement the functionality in different ways, using either a function, a trigger function or a rule. None of them are perfect. There are trade-offs to be made. Continue reading

SQLAlchemy Declarative Class Reflector

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

SQLAlchemy has a nice reflection facility which takes for example a database table name as argument and produces a Table object out of it for manipulation. However, those objects do not behave like the objects produced by declarative classes, which are easier to work with. Here’s a little class that helps to bridge that gap by reflecting proper declarative classes from database tables. It has only been tested with PostgreSQL, but it may work with other databases as well. Continue reading

Editing Tabular Data in Vim

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

Helpful settings for editing tabular data:

Noexpandtab disables expanding of inputted tabs to spaces. Adjust the number of spaces to your liking. Tabstop sets the visual appearance of tab stops (here 16 spaces). Continue reading

Developer Mode for the Samsung Galaxy S4

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

From: Developer Mode for the Samsung Galaxy S4

Get to the phone’s settings by tapping ‘menu’ from the home screen and then tapping ‘settings’

  • tap on ‘more’
  • tap on ‘software information’
  • tap on ‘About Device’
  • find the build number, and tap it 7 times
  • on the 7th tap, a prompt should appear alerting you that Developer Options has been unlocked

You may also wish to:

And after that you must accept the USB connection by tapping OK in the prompt on the device after you connect it.

How to prefer IPv4 over IPv6 for some hosts

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

If an IPv6 address is unreachable, but you can reach the IPv4 one, you can set the preference to IPv4 for that particular address by adding a line such as this in /etc/gai.conf:

That will set the preference for host 198.145.11.105 to IPv4.

See gai.conf(5) for details.

 

How to install the latest node.js on Ubuntu

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

How to install the latest node.js on Ubuntu?

 

Linux IPv6 Router: RADVD + DHCPv6

  • 3.50 / 5 5
2 votes, 3.50 avg. rating (76% score)

Unlike IPv4, which uses DHCP for configuration, IPv6 uses the Neighbor Discovery Protocol to configure addresses and gateways. Unfortunately, originally the protocol had no means of providing addresses of DNS servers to clients, making it necessary to use  DHCPv6 for that purpose. Modern Linux and Mac OS X machines are able to use the IPv6 Router Advertisement Options for DNS Configuration (RFC 6106), but to my knowledge, Windows clients are not able at the moment. Here’s how to configure a Linux router using radvd and the ISC DHCP daemon. Continue reading

PostgreSQL Database Cluster Migration Notes

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

I had to migrate a pretty big database cluster from one server with PostgreSQL 8.4 to a new server with 9.2 There we multiple apps using the databases, and the downtime had to be minimal. Luckily, the databases were split to multiple schemas, and there were only a few tables in a couple of schemas that were in active use at the time of the migration.

The pg_dump tool was very helpful in this operation. First, I set up ssh public key authentication between the postgres users from the source to the destination server. Then I ran the first full cluster dump to the new empty cluster. This can be done while users are actively using the source database, as long as you know which schemas, tables and sequences are in use, so that they can be copied again after shutting down applications: Continue reading

Sonera CStream Messaging Web Service API with Python and SUDS

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

In this article I will show you how to use the Sonera CStream Messaging Web Service API to send an SMS using Python, and a library called  SUDS. The CStream API is two-way service for both sending and receiving messages. You obviously need to pay for the service to get access. After you have your credentials, you can start using the service.

The SUDS is a lightweight SOAP Python client for exploring and using web services. A recent version can be installed on Debian based distros with “sudo apt-get install python-suds”, or on almost anything with “pip install suds”. Continue reading

Init Script for Daemonizing Non-Forking Processes

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

Sometimes you have an executable which does not fork to the background, but you need to control it with init scripts, so that it does indeed run in the background. Here’s a pretty generic init script for that. It allows you to configure these:

Continue reading

HP ProLiant Management Component Pack on Ubuntu

  • 0.00 / 5 5
0 votes, 0.00 avg. rating (0% score)

HP seems to have set up a package repository for Ubuntu 12.04, which is an improvement since I last checked a few years ago. To use the repo, add the following line to /etc/apt/sources.list:

Run “sudo apt-get update”.

You can install a number of software packages from the repository:

  • hpsmh: HP System Management Homepage
  • hp-smh-template: HP System Management Homepage Templates
  • cpqacuxe: HP Array Configuration Utility, web-based
  • hp-snmp-agents: Insight Management SNMP Agents for HP ProLiant Systems
  • hponcfg: RILOE II/iLO online configuration utility
  • hp-health: HP System Health Application and Command line Utility Package
  • hpacucli: HP Command Line Array Configuration Utility
  • ams: Agentless Monitoring Service for HP ProLiant Gen8 Systems Continue reading