[GiM logo]gim.org.pl is down || odświeżony jogger (v.0.4) GiMa

gim photo
Michał 'GiM' Spadliński
programowanie, google, *nix, av, re
last buzz

mini:
  • The Cambist and Lord Iron

    by Daniel Abraham for free @issuu or @POD Castle.

  • Dark Side of C++

    [link]

  • Lost

    No i koniec.

  • Vista vs Open / Save As Dialog Box

    Zdaje się, że od XP 'Save As' i 'Open' pamiętają folder, gdzie ostatnio się pracowało. Jest to dość irytujące w z zachowaniem, do którego większość się chyba przyzwyczaiła, gdzie dialogi te startują w aktualnym katalogu.

    Żeby to zmienić w Viście, wystarczy odebrać sobie prawa do odczytu klucza: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\comDlg32\LastVisitedPidlMRU. To pewnie nie jest najlepszy sposób, ale dla aplikacji z których korzystam DZIAŁA :P

  • Holy fsckin cow

    Zastanawiam się, dlaczego nie wygooglałem tego wcześniej: Speed up powershell startup

  • numery tygodni w Google Calendar

    Nie wiem czy da się to zrobić, jakoś prościej, w każdym razie znalazłem takie fajne coś: google calendar week numbers

  • xps przykłady dokumentów
    Może komuś się przyda: klik
  • D tutorials
    Kilka video tutoriali o podstawach D, różnych edytorach instalacji dmd, tango.
  • niech mi z oczu zejdą

    Każdy problem ma rozwiązanie,
    jeśli nie ma rozwiązania, to nie ma problemu, nie ma problemu

    Ej, człowieku to jest przecież jakiś horror,
    to nie tędy dróżka, jeśli chcesz żeby jakaś fróźka
    poszła z tobą do ee kina

  • powershell - path

    Do zapamiętania:
    PS> $env:path
    PS> $env:path = $env:path + ";c:\blah"

  • Jakiś czas temu...
    ...napisałem, że Programowanie Uogólnione (generic programming), brzmi syfnie, wycofuję się z tego zarzutu, po pierwsze sam zaczynam stosować to sformułowanie, poza tym po dłuższym namyśle brzmi całkiem nieźle, na pewno lepiej niż 'programowanie generyczne', także trochej, zwracam honor : )
  • Kimya Dawson - Loosy Lips
    we won't stop until somebody calls the cops
    and even then we'll start again and just pretend that
    nothing ever happened

Szorty gima (obsolete):
loading...
07
październik-2010
204302

A friend of mine, had a problem today (with Python) which voils down to the following piece of code:

  • f = open('input.txt')
  • c = f.readlines()
  • # here were different operations
  • # on c, but that's not really important
  • print len(c)

Don't ask why there is readlines() in the first place, that's not the problem.
The problem was, that c had wrong number of lines. However answer to that lies in python's documentation:

Read until EOF using readline() and return a list containing the lines thus read. If the optional sizehint argument…

Unfortunatelly the file contained some random bytes, among different bytes there was also character with hex value of 0x1A. Now let me quote everyone's favourite source of information - wikipedia:

In the MS-DOS operating system, this character is used to indicate the end of a file or the end of user input in an interactive command line window. This behavior was borrowed from the earlier CP/M operating system.

Some operating systems such as the pre-VMS DEC operating systems, along with CP/M, tracked file length only in units of disk blocks and used Control-Z (SUB) to mark the end of the actual text in the file. For this reason, EOF, or end-of-file, was used colloquially and conventionally as a TLA for Control-Z instead of SUBstitute.

There is simple "solution" to this problem:

  • f = open('input.txt', 'rb')

Since CP/M was mentioned twice here, I can't resist to quote famous words of a man I've always regarded as a brilliant visionary - Gary Kildall (but unfortunately rather poor businessman for that matter) (the quote relates to int 21h/AH=09h):

"Ask Bill [Gates] why the string in function 9 is terminated by a dollar sign. Ask him, because he can't answer, only I know that."

catz: [eng.lish] [kom.puterowe] [micr.osoft] [pro.gramowanie]
tagz: [0x1A] [EOF] [python] [readline] [readlines] [windows]
Dodaj swoją opinię
03
październik-2009
104040

Truly saying I'm not much interested in C++0x (or rather C++1x :P).
Today I've stumbled upon few examples of delegates:

  1. [](int x, int y) -> int { int z = x + y; return z + x; }
  2. [&, foo](int x) { sum += x; prod *= foo; }

In the second code & refers to 'full closure' (so sum and prod are variables from that closure, accessed by reference), and foo is copied from the closure by value (i.e. any changes to foo inside the delegate won't be seen outside the delegate).

Truly saying, I don't mind it, but ...
C++ already has awful syntax (you can argue, but that's a fact :P)
Am I wrong or is the proposal (?) of delegates' syntax are is just über-crappish?

If you look at above samples and your answer is nope, here's one more for you:

  1. [&](int* foo, int i){i[foo] += (bar->*baz)(i); }

P.S. Your comments will be appreciated

catz: [eng.lish] [kom.puterowe] [pro.gramowanie] [Techblog]
tagz: [] [c++0x] [c++1x] [syntax-horror]
65 komentarzy
25
kwiecień-2009
153046

I hear voices, wait a minute, that's not what I've meant.
I've heard there are more and more people interested in DDL (D Dynamic Libraries) under Linux. This is first of short series of posts that will describe some changes I've made in h3r3tic's team0xF's repo.

Pokaż więcej...

catz: [eng.lish] [kom.puterowe] [programowanie w D]
tagz: [d] [d programming language] [ddl] [język programowania D] [linux]
1 komentarz
14
styczeń-2009
044409

Nice title, huh?
Descent plugin is being cooler and cooler, but you've probably seen it on videos.
One of the things that was driving me mad and kept me away from descent was compilation process.

Java guys probably know apache ant build system (and if they don't they definitely should). I'm going to describe here, how to force eclipse to use descent plugin's ant tasks to build D projects. I'm using this at least for a few months now and I prefer it much more over rebuild method described on Descent page, I was wondering why this method is not described there.

First there are some basic informations, how to install descent with eclipse 3.4, how to set-up a project, the rest is about ant usage.

Eclipse/Descent basic stuff

I'm using Eclipse ganymede since it's better than its predecessors. First quick installation for all the lazy bastards out there:

  1. Go and grab eclipse, I've downloaded IDE for Java Developers since it has ant plugins ready to use.
    (If you have eclipse installed already, you probably could just install apache ant stuff in software updates).
  2. Unpack and start eclipse, choose workspace, go to Help -> Software updates, Available software
    choose Add site and enter descent's site: http://downloads.dsource.org/projects/descent/update-site and OK, it should appear in the middle table, select it and Install,
  3. After few clicks and minutes Descent should be installed and Eclipse will ask you for the start, do so
  4. When it'll start again close the welcome screen, and first of all, turn on D-perspective (Window->Open perspective->Other->D), if it's not there it means you haven't installed descent plugin properly
  5. Next we'll add tango to user libraries to make project configuration simpler. Go to Window->Preferences, choose D->Build path->User libraries, choose New and enter meaningful name (tango? :>), choose Add directory and select directory with your tango lib (I got it under /opt/dmd/include/d),
  6. Go to General->Editors->Text editor->Spelling, and disable spelling engine, otherwise you'll get most of the code red-underlined :]

Now time for some fun stuff.
eclipse descent

  • Choose File->New->Project, select D project, enter name (I've used DSample) and you can click Finish,
  • Right click on your project, choose New->module, enter module name (I've used sample.d) (for simplicity everything will be in default package,
  • Now in editor window type 'main' and press Ctrl+Space (you'll love this shortcut ;)), editor should show suggestions, after hiting Enter you'll have basic main function,
  • If you try typing 'Std' [Ctrl+Space], you'll see there are no fancy proposals, right-mouse-click on your project, choose Build Path->Add Libraries, choose User Libraries, select tango (added in step 5) and click finish,
  • Now after typing 'Std' [Ctrl+Space] you should see some proposals

eclipse descent
Now let's play with ant..

Descent + ant, honey

One night I was playing with descent jar files and I've noticed interesting jar inside descent.core.
Open up your favourite terminal and extract needed jar.

  1. mkdir -p ~/.ant/lib
  2. cd ~/.ant/lib
  3. unzip ECLISPE_DIR/plugins/descent.core_0.5.3.20081231.jar ant_tasks/descent-ant.jar

ECLIPSE_DIR above is of course your eclipse installation dir (~/eclipse in my case :])
Now go back to eclipse, Window->Preferences, Ant->Runtime (Classpath), click Add External JARs and add your ~/.ant/lib/descent-ant.jar archive.
Next go to Tasks menu we'll add two tasks:
I've entered name "descent.D", choose descent-ant.jar from drop-down list, and click on: "/descent/ant/tasks" and choose "D.class"
Now do the same using "descent.DBldNum" and choose "DModuleBuildNumber.class" file.

We're going to create ant build file, but before that let's create build.properites file that will held some basic data in easily editable format.
Press Ctrl+N, choose General->File, and enter build.properties as it's name.
Here is content of my properties file:

  1. compiler.dir = /opt
  2. compiler.type = dmd-linux
  3. src.dir = .
  4. dest.dir = bin

compiler.dir is a path to compiler (without dmd/bin/dmd, descent appends it)
Press Ctrl+N and in filter box type xml, and chose XML, click next, and enter build.xml as a filename, Using bottom tabs choose Source instead of Design
I've created following build.xml (I'm not pasting it here, since this would be quite senseless, but you can take a look at it at codepad.org.
Build file is specific for linux, if I remember correctly my build.xml under windows was simpler than that one.
As you see most of the file is definition of compile macro which takes one parameter (bldtrg). (EDIT: you can find list of all possible parameters for descent.D task here)
Let's forget about that macro for a moment and take a look down at possible targets:

  1. <target name="build-number">
  2.   <descent.DBldNum file="${src.dir}/sample_bn.d" fqn="sample_bn" />
  3. </target>
  4. <target name="compile" depends="build-number" description="Compiles sample">
  5.   <compile bldtrg="sample"/>
  6. </target>

This looks quite clean don't you think?
Now you could right-mouse-click on the build.xml file, choose Run-as ->Ant build file but this is uber-lame.
Instead go to Window->Show View->Other and select Ant. I like to keep this window in lower-wight corner. Double click on any listed target will execute it (along with dependencies).
I have binded Ctrl+Shift+Q A to Show View (View: Ant), this way I can fast switch to ant window :).
eclipse descent

What's cool about it is that you can have multiple build targets (one can build few executables) and have all of them visible and easily accessible.
I'm not going to encourage anybody to use ant, but it's really cool tool, take a while to peek into ant's documentation, especially ant tasks.

catz: [eng.lish] [kom.puterowe] [programowanie w D] [Techblog]
tagz: [d] [d programming language] [descent] [eclipse]
6 komentarzy
16
styczeń-2007
151303

I had some problems with mixer module in E17 (with alsa), here's what I've done to fix it.

  • First, make sure you have alsa development files (this is libasound2-dev pakcage in ubuntu)
  • recompile e17 mixer module with alsa support
    • cd e_modules/mixer
    • ./configure --disable-oss --enable-alsa && make
  • install recompiled module, by issuing commands
    • enlightenment_remote -module-unload mixer
    • rm -rf ~/.e/e/modules/mixer
    • rm -rf ~/.e/e/config/default/module.mixer.cfg (remove OLD settings)
    • make install (it can be done as a user, module wil be located in ~/.e/e/modules/)
    • enlightenment_remote -module-load mixer
    • enlightenment_remote -module-enable mixer
  • Add mixer module to one of your shelves (right-mouse-button on any shelf, and 'Configure shelf contents'
  • Right-click on mixer icon, and chose Configuration. You should be able to choose one of available mixers (I use PCM, since Master mixer seemed not to work)
  • If you have multimedia keyboard, you can add key-bindings (take a look at sample file with keycodes for xmodmap (in polish, but you should get the idea)):
    • enlightenment_remote -binding-key-add ANY XF86AudioLowerVolume NONE 0 decrease_volume ''
    • enlightenment_remote -binding-key-add ANY XF86AudioRaiseVolume NONE 0 increase_volume ''
    • enlightenment_remote -binding-key-add ANY XF86AudioMute NONE 0 mute ''
catz: [eng.lish] [kom.puterowe] [Xo.rg]
tagz: [alsa] [e17] [mixer module] [not working]
Dodaj swoją opinię
13
sierpień-2006
223139

Grzegorz Niemirowski suggested, that I should provide script, that I've described lately.
So here is automated script for Microsoft Power Shell.

08
sierpień-2006
185245

You've probably heard about Microsoft PowerShell. This small note will show you how to analyze (well at least start to analyze) Windows PE executable files with just use of PowerShell.

Pokaż więcej...

15
lipiec-2006
192345

My job in Google Summer of Code is to write two unpackers for Clam AntiVirus for MEW and UPack exe-packers. MEW seems to be beaten-up. Now it's time for UPack. Some more information about both of them will be realeased in later.

What is an exe-packer? It's a program that allows to compress binary of other programs, They are decompressed on the fly after running exe-packed file.
Malware writers thought it would be cool to make executable smaller (so it could go even faster through the net and occupy less disk-space). Some Antivirus systems instead of unpacking compressed file, match exe-packer.
This is very wrong. Why? Many demoscene programs are exe-packed (this is very useful if you want to fit in 64k or 4k), so matching by exe-packer can cause much false-positives.

13
lipiec-2006
171823
Hash from apcoh has sent nice nredquiz. And I got 100 percent, Hooray (?), I'm truly geek!
My computer geek score is greater than 100% of all people in the world! How do you compare? Click here to find out!
UPDATE: I answered truly and honestly.
UPDATE2: I answered after beer ;-)