Creating a File with Arbitrary Size on Ubuntu

If you want to create a file with arbitrary size on Ubuntu, you can issue the following command:

dd if=/dev/zero of=dummy.dat bs=1 count=0 seek=1G

The program reads from an input file, in this case, it uses 0 as an input. The output file is written with file name “dummy.dat”. The bs stands for byte size. The count specifies the number of blocks to copy. The seek skips this space before writing.

The sample code above generates a file with size 1 GB. In my case, it was created in less than a second. Remember that 1 KB = 1024 bytes.

Here are some values that you can use for the seek flag: T (TeraByte), G (GigaByte), M (MegaByte), K (KiloByte), and many more. For more information, you can see the manual of the dd program.

A Simple Random String Generator Implemented in Python

The general idea of this program is that given a grammar, construct any random string that follows the grammar rules. It is guaranteed that all the strings produced will be valid.

For the grammar, all the non-terminals are positioned on the left side while the equivalent values are positioned on the right side.

This is the grammar provided to us by our professor. This is a grammar for a simple calculator. The assumption here is that the grammar is Context Free and that the string has a finite length. Continue reading

String Rewriting Parser Implemented in Python

The program assumes that you will be providing Context-Free Grammar, otherwise it will not work properly. The idea of the program is to break a sentence down to its atomic elements. It follows the concept of String Rewriting System.

Given a sentence: abbabab

and grammar rules:

  1. ab -> S
  2. aS -> S
  3. Sb -> S
  4. SS -> S

The program determines whether the sentence can be parsed or not. It can be parsed if the sentence follows the grammar rules. Continue reading

Simple Finite State Parser Implemented in Python

This is a Simple Finite State Parser that checks whether is an English sentence is syntactically correct or not based on the grammar provided by my teacher.

The following is the Finite State Diagram of the grammar:

grammar
The program reads from a file a dictionary of valid words which also contains the type of the word. See sample below: Continue reading

Windows 8.1 Managing Network Profiles

Open the Registry Editor (regedit via Run command) and go to this directory:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

Each network location is represented by a folder entry under this directory.

If you want to set up again the network locations when the network adapter connects to the network, delete all the subfolders of Profiles folder.

If you want to rename the network location, click on the right subfolder and edit the key named ProfileName and input the name you desire for the network location.

Script File to Backup SimStudent Logs

My group and I are performing an experiment in one of our subjects. We are using the SimStudent program which is locally installed in approximately 80 machines. We needed a way to copy all the logs of all the program instances and store them in a network storage.

This is the script I made. This will only work in Windows.

@echo off

REM	Written by: Yancy Vance M. Paredes, March 18, 2014

REM 	Go to the directory where the log folder is located
cd simstudent\SimStAlgebraV8

REM 	Prompt the user to enter the correct student number
SET /p STUDENT_ID="Enter student ID (ex: 02 [with leading zero]): "

REM	Prompt the user to enter the session number
SET /p SESSION_ID="Session No. (1, 2 or 3): "

REM	Prepare the target path based on the user's input
SET TEMP_PATH=Session %SESSION_ID%\ADDU02%STUDENT_ID%

REM	Make sure to update this one to point to the UITO network storage
SET TARGET_PATH=M:\logs\%TEMP_PATH%\

REM echo %TARGET_PATH%
REM	Copy the file to the network storage, prompt for overwriting
REM	and copy everything inside the log folder to the new directory
xcopy log "%TARGET_PATH%" /s /-y

The assumption here is that the script is located just outside the SimStudent directory.

How to Calibrate Samsung Devices’ Magnetic Sensor

If your Samsung device comes with a magnetic sensor, you can calibrate it.

The first thing that you have to do is go to the Diagnostic Menu by issuing the code *#0*# . Afterwards, go to Sensor. You will know if the magnetic sensor is calibrated or not. See the picture below.

2014-02-11 23.11.56

The value should be 3 and not 1. By the way, this screenshot was taken from my Note 10.1. To calibrate it, just shake your device until it becomes 3. Just wait for a few minutes before the value changes. See the picture below. Continue reading

Setting GRUB’s Default Operating System

If you are using GRUB as your boot loader and you want to change the default operating system that is highlighted in the list, just follow these simple steps:

You should do this on your Linux machine. My current setup: dual boot of Windows 8.1 and Ubuntu 13.10.

Open the terminal and issue the following command:

sudo nano /etc/default/grub

Look for the variable GRUB_DEFAULT. Set the value to any integer value. It works similarly with the index of an array in C or Java.

2014-02-16 22.42.50

In the list above, you can set the value from 0 to 3, inclusive.

After changing the file, save it and issue the following to update the GRUB:

sudo update-grub

Finally, restart your system to see if it works.