Code

so here is vyw

I supposed to write this weeks ago though, anyway. Here is vyw, it’s a client side file browser. Vyw actually is a continuation of this post. At least the idea was already popped up around that time, but I only had the chance to tinker around it few weeks ago. So the idea was to have this fully functional file browser, or specifically, images browser with thumbnail view, which usually achieved with server-side app, backed only with nginx.
Read more

Things I did randomly last week

I actually have like 3 post drafts queued before this, 2 reviews for the Hibike! Euphonium ending, and a note on how I rewrote shreds with ES2015, ractiveJS, and a bastardized Flux architecture. But anyway, I kind of in the mood for writing about things I did last week. So it just came to me that it’s probably about time to rotate my SSH keys, random public keys started to piled up at my GitHub and Bitbucket account and I decided to remove them all and start with the new one.
Read more

git unhg

I should tidy up my $HOME/bin directory, some of actually useful scripts and configurations were scattered here and there. Anyway, I’ve been using this one script when I work with shreds: #! /usr/bin/env bash interim_branch=default rollgit() { [[ $# -ne 1 ]] && { echo 'wrong number of arguments, USAGE:' printf "\tgit roll <branch>\n" exit 1 } git rebase $1 && git checkout $1 && git rebase $interim_branch && git branch -D $interim_branch } unhg() { [[ $# -ne 2 ]] && { echo 'wrong number of arguments, USAGE:' printf "\tgit unhg <remote> <branch>\n" exit 1 } git-hg fetch $1 && git checkout -b $interim_branch FETCH_HEAD && git roll $2 } self=$(basename $0) case $self in git-unhg) unhg $* ;; git-roll) rollgit $* ;; *) echo 'Invalid command specified' ;; esac Shreds source revisions is actually tracked on mercurial.
Read more

Code Tidbits: wrk pt.1

I have this plan to do some write up series related to programming and such, mostly as another form of practicing C systems programming. Just when I wondered about what topic I should write, I found this gem written by Will Glozer. So I think I can study the source code and write some little explanation here and there about the code, hence the tidbits. Feel free to critic and correct things if you find mistakes on this. It would be my honour.

How things work from here

I’ll make the writings into several parts, each explaining a module or two around the project. I will start from the nuts and bolts first, going to the main program/module at the last part.

Intro to wrk

wrk, as described by its author, is a modern http benchmarking tool. It’s written in C, event-based, and some part of it is actually stolen from redis sorce base. It’s fairly easy to use, and the stats is comprehensive, you can grab the source from here. Just type make to compile, and you’ll be ready to benchmark your website.

I kinda like the source code for its simplicity and learn a lot from them. The library used from redis including zmalloc and ae. I will going into zmalloc, before that, lets see this aprintf first.

Read more

The Hook

Referring to previous post, this is the post-receive script I used for the blog. Actually I forgot to attach this to the previous post, so I decide to just create another post for this. {% include_code post-receive lang:sh post-receive %} The locale entries is needed by jekyll, since it’s not set at git/www user environment Also don’t forget to add this entry to sudoers git ALL=(www) NOPASSWD: ALL Basically, it tells sudo to allow git to act as www without any password.
Read more

imgpop

Now I will going into technical details inside imgpop.

Like I said in the previous post. I extends Brian’s imgpopup and do some makeup to things. At the backend, I use mini_magick to actually save the resized image, and use that as preview/thumbnail. Here’s the snippet.

#...#
# Open the source image, and scale it accordingly.
image = MiniMagick::Image.open(image_path)
vars['full_width'] = image[:width]
vars['full_height'] = image[:height]
image.resize "#{@percent}%"

rpath = source+ resized_image
if not File.exists? rpath
# Actually save the image
  image.format "jpg"
  image.quality "92"
  image.write rpath

  # This is the tricky part
  # we should register the new created file
  # since Jekyll already indexed all files before
  context.registers[:site].static_files << StaticFile.new(
          context.registers[:site], source, File.dirname(@path.sub(%r{^/}, '')),
          "resized_#{File.basename(@path)}")
  print "image saved to #{rpath}\n"
end
#...#
Read more

Image viewer is up!

% center My current desktop with cinnamon: 2nd monitor % center My current desktop with cinnamon: 1st monitor Yay, it’s up. You can click images above to try it out. a pop-up will appear with full sized image, and it’s draggable! You can also try hover the upper area of the popup to see the tagline/title and download link for the image. Credits to Brian Clapper.
Read more

securing html form

Why we have to make sure our html form is secure?? ‘cuz we don’t want someone doing something silly to our website, avoiding cross site scripting and negate injection or hijacking… well, I guess there’s a lot of method to prevent those things… mm, and I found mine… dunno if someone already come up with the same method… I don’t do any research on this… so I won’t claim anything about the method… and I hope no one do something retard like claiming this method as their… Oh, and I think this method is old… not too smart… and might be easy to get hacked… So, the problem is : 1.
Read more

fair good music player...

browser so you can select files directly from your file system… 2. Audacious well with ‘old winamp’ like UI, this app is more easy to use… nobody never use winamp isn’t it…? 3. Banshee : this one is good, but I don’t really understand how the cover fetched, since only some of them loaded… 4. Rhythmbox : slightly slower, and the playlist management annoys me. 5. Totem : not count, since its media player, not as good as MPlayer though … browser so you can select files directly from your file system… 2.
Read more

more or less into the moon

nothing…. it’s just an ordinary day… okay this is for today : Lua lua is scripting language and widely used as an embedded language for the other more complex program. some of plugin in Adobe PhotoShop made using lua, some rts game generate map and other stuff from lua script, and if you work for fansub team as a karaoke styler.. it’s a common sense to use lua script for karaoke automation… lua name taken from portugese, which is meaning ‘moon’.
Read more