Permalink
Browse files

unifying with supersnippets

  • Loading branch information...
1 parent 69d1ab0 commit dd1fa5db3f8b92eb7e502662e4d3a5d67b7b50f3 @sole committed Aug 21, 2010
View
11 README
@@ -19,13 +19,24 @@ Old style 'table' of contents:
|
+-- wav2ogg - encode all .wav files in current directory to .ogg
|
++ psp
+|
++-- log_buttons - dump button presses and other events (uses SDL)
+|
+ utils
|
++-- filesystem_manipulation
+|
++---- split_files_into_folders_by_letter.py - organise files into folders using their first letter
+|
++---- zip_folder.py - zip a series of files with python, using zipfile
+|
+-- image_convert - image conversions. Currently only png2jpg, more to come I guess...
|
+-- screenshots - take periodical screenshots of your desktop
|
+-- screencast2 - making desktop screencasts in Ubuntu. Capture both screen AND PulseAudio. No Jack!
+|
+ web
|
+-- fix_entities - converts (some) html entities to its UTF8 counterparts
View
98 psp/log_buttons/main.c
@@ -0,0 +1,98 @@
+// Soledad Penades http://soledadpenades.com
+#include <stdlib.h>
+#include "SDL.h"
+#include "SDL_main.h"
+
+#ifdef PSP
+ #include <pspdebug.h>
+ #define printf pspDebugScreenPrintf
+#else
+ #include <stdio.h>
+#endif
+
+#define W 480
+#define H 272
+
+SDL_Surface *screen;
+
+void printJoystickInfo(SDL_Joystick *joystick)
+{
+ int index;
+
+ index = SDL_JoystickIndex(joystick);
+
+ printf( "JOYSTICK INFO\n\n"
+ "Index: %d\n"
+ "Name: %s\n"
+ "Num axes: %d\n"
+ "Num balls: %d\n"
+ "Num hats: %d\n"
+ "Num buttons: %d\n",
+ index,
+ SDL_JoystickName(index),
+ SDL_JoystickNumAxes(joystick),
+ SDL_JoystickNumBalls(joystick),
+ SDL_JoystickNumHats(joystick),
+ SDL_JoystickNumButtons(joystick)
+ );
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Joystick *joystick = NULL;
+ SDL_Event event;
+ int done = 0;
+
+ if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
+ {
+ printf("init error: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ if((screen = SDL_SetVideoMode(W, H, 32, 0)) == NULL)
+ {
+ printf("SetVideoMode: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_Delay(1000);
+
+ if(SDL_NumJoysticks())
+ {
+ joystick = SDL_JoystickOpen(0);
+ printJoystickInfo(joystick);
+ }
+ else
+ {
+ printf("No joystick detected\n");
+ }
+
+ done = 0;
+ while(!done)
+ {
+ while(SDL_PollEvent(&event))
+ {
+ switch(event.type)
+ {
+ case SDL_JOYBUTTONDOWN:
+ printf("Pressed button %d\n", event.jbutton.button);
+ break;
+ case SDL_JOYAXISMOTION:
+ printf("Axis motion: j index = %d axis = %d value = %d\n", event.jaxis.which, event.jaxis.axis, event.jaxis.value);
+ break;
+ case SDL_QUIT:
+ done = 1;
+ break;
+ }
+ }
+ }
+
+ if(joystick)
+ {
+ SDL_JoystickClose(joystick);
+ }
+
+ SDL_Quit();
+
+ return(0);
+}
View
24 utils/filesystem_manipulation/split_files_into_folders_by_letter.py
@@ -0,0 +1,24 @@
+# soledad penades www.soledadpenades.com
+
+import os
+import shutil
+import sys
+
+if len(sys.argv) > 1:
+ folder = sys.argv[1]
+else:
+ folder = '.'
+
+for item in os.listdir(folder):
+
+ full_path = os.path.join(folder, item)
+
+ if os.path.isdir(full_path):
+ continue
+
+ dst_folder = os.path.join(folder, item[0].lower())
+
+ if not os.path.exists(dst_folder):
+ os.mkdir(dst_folder)
+
+ shutil.move(full_path, os.path.join(dst_folder, item))
View
34 utils/filesystem_manipulation/zip_folders.py
@@ -0,0 +1,34 @@
+# soledad penades www.soledadpenades.com
+
+import os
+import sys
+import zipfile
+
+
+if len(sys.argv) > 1:
+ folder = sys.argv[1]
+else:
+ folder = '.'
+
+for item in os.listdir(folder):
+
+ full_path = os.path.join(folder, item)
+
+ if not os.path.isdir(full_path):
+ continue
+
+ dst_filename = item + '.zip'
+
+ dst_item = os.path.join(folder, dst_filename)
+
+
+ if os.path.exists(dst_item) and os.path.getsize(dst_item) > 0:
+ continue
+
+ output_file = zipfile.ZipFile(dst_item, "w", zipfile.ZIP_DEFLATED)
+
+ for item_file in os.listdir(full_path):
+ output_file.write(os.path.join(full_path, item_file), item_file)
+
+ output_file.close()
+

0 comments on commit dd1fa5d

Please sign in to comment.