This has bugged me for a while for a personal power monitoring project.
$datetime->modify('-3 months');
This has bugged me for a while for a personal power monitoring project.
$datetime->modify('-3 months');
#include <stdio .h> #include <iostream> using namespace std; int main() { int sum = 0; for(int x = 0; x < 1000; ++x) { std::cout << ". "; if (x % 3 ==0 || x % 5 == 0) { std::cout << x << " "; sum += x; } } std::cout << "\nSum of numbers which can be divided by 3 and 5 is " << sum << "\n"; return 0; };
Perl | Use these Perl Epoch routines |
PHP | mktime(hour, minute, second, month, day, year) ![]() |
Ruby | Time.local(year, month, day, hour, minute, second, usec ) (or Time.gm for GMT/UTC input). To display add .to_i |
Python | import time first, then int(time.mktime(time.strptime('2000-01-01 12:34:00', '%Y-%m-%d %H:%M:%S'))) - time.timezone |
Java | long epoch = new java.text.SimpleDateFormat ("dd/MM/yyyy HH:mm:ss").parse("01/01/1970 01:00:00"); |
VBScript/ASP | DateDiff("s", "01/01/1970 00:00:00", time field) ![]() |
MySQL | SELECT unix_timestamp(time) Time format: YYYY-MM-DD HH:MM:SS or YYMMDD or YYYYMMDDMore on using Epoch timestamps with MySQL |
PostgreSQL | SELECT extract(epoch FROM date('2000-01-01 12:34')); With timestamp: SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08'); With interval: SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', time field) |
JavaScript | use the JavaScript Date object |
Unix/Linux | date +%s -d"Jan 1, 1980 00:00:01" Replace ‘-d’ with ‘-ud’ to input in GMT/UTC time. |
Perl | Use these Perl Epoch routines |
PHP | date(output format, epoch); Output format example: ‘r’ = RFC 2822 date ![]() |
Ruby | Time.at(epoch) |
Python | import time first, then time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(epoch)) Replace time.localtime with time.gmtime for GMT time. ![]() |
Java | String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000)); |
VBScript/ASP | DateAdd("s", epoch, "01/01/1970 00:00:00") ![]() |
MySQL | from_unixtime(epoch, optional output format) The default output format is YYY-MM-DD HH:MM:SS more … |
PostgreSQL | PostgreSQL version 8.1 and higher: SELECT to_timestamp(epoch); ![]() SELECT TIMESTAMP WITH TIME ZONE 'epoch' + epoch * INTERVAL '1 second'; |
SQL Server | DATEADD(s, epoch, '1970-01-01 00:00:00') |
Microsoft Excel | =(A1 / 86400) + 25569 Format the result cell for date/time, the result will be in GMT time (A1 is the cell with the epoch number). For other timezones: =((A1 +/- timezone adjustment) / 86400) + 25569. |
Crystal Reports | DateAdd("s", {EpochTimeStampField}-14400, #1/1/1970 00:00:00#) -14400 used for Eastern Standard Time. See Timezones. |
JavaScript | use the JavaScript Date object |
Unix/Linux | date -d @1190000000 Replace 1190000000 with your epoch, needs recent version of ‘date’. Replace ‘-d’ with ‘-ud’ for GMT/UTC time. |
PowerShell | Function get-epochDate ($epochDate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochDate)) } , then use: get-epochDate 1279152364 . Works for Windows PowerShell v1 and v2 |
Other OS’s | Command line: perl -e "print scalar(localtime(epoch))" (If Perl is installed) Replace ‘localtime’ with ‘gmtime’ for GMT/UTC time. |
% for i in $(cat testbla); do echo $i; done foo bar baz boo % export IFS=$'\n' % for i in $(cat testbla); do echo $i; done foo bar baz boo
Change
Preferences > Keys > “content assist”
to something that doesn’t collide with Quicksilver.
Damnit, yes – you need to do another /save
after /layout save
.
stumbled across wmctrl. this page has some nice examples
q + lowercase letter to start recording macro, q again to stop
ctrl+v, select, shift + I for multiline editing.
Stolen shamelessly from this site.
map <c -J> </c><c -W>j</c><c -W>_ map </c><c -K> </c><c -W>k</c><c -W>_ set wmh=0 </c>
The first two lines allow you to switch between splits much more smoothly — just press
The last line allows splits to reduce their size to a single line (which includes the filename and position); this saves a lot of space when you have many splits open. By default, vim forces splits to include an additional line that contains the line of text the cursor was on in that file.
This gives you some sort of stacking functionality like in wmii
There are too many hard links to a file or directory on a filesystem. The exact number allowed is file-system dependent. Eg /usr/src/linux-2.4.19/include/linux/sysv_fs.h contains
enum { XENIX_LINK_MAX = 126, /* ?? / SYSV_LINK_MAX = 126, / 127? 251? / V7_LINK_MAX = 126, / ?? */ COH_LINK_MAX = 10000, };
while /usr/src/linux-2.4.19/include/linux/ext3_fs.h has
define EXT3_LINK_MAX 32000
and /usr/src/linux-2.4.19/include/linux/reiserfs_fs.h has
define REISERFS_LINK_MAX (MAX_US_INT - 1000)
(for maximum unsigned integer on the system).
This could be caused by a directory having too many subdirectories (each subdirectory has .. as a hardlink to it’s parent directory which causes that directory’s hardlink count to be increased by one. So yes, this does mean that you are limited to 32000 subdirectories in one directory in ext3, even if you have hashdirs enabled.) As a consequence of this you can stat(2) a directory and add one (for ..) and you will know how many directories are in the current directory. (or subtract one (for .) to find out how many subdirectories there are).
Some file systems (such as FAT) don’t have hardlinks so the hardlink count can’t overflow, and you can’t rely on the hardlink count of a directory to be representive of how many subdirectories it has.
What a confusing world we live in.