Posts by Chang Park

FDMA, TDMA, and CDMA

fdma

FDMA (Frequency Division Multiple Access)

  • Vary frequencies for each user.
  • If number of users increases, it becomes complicated.

TDMA (Time Division Multiple Access)

  • Using same frequency, divide into many time slots.
  • Allocating different time slot for each user.
  • They can speak only when their turns.

CDMA (Code Division Multiple Access)

  • Each pair communicates in different languages.
  • The mobile and base station are able to distinguish between signals transmitted simultaneously over the same frequency allocation.

Bandwidth and Frequency

bandwidth

Bandwidth (bps – bits per second)

  • Amount of data that can be transmitted in per unit time.
  • Difference between highest frequency and lowest frequency (bandwidth = high – low)

Frequency (Hertz)

  • Number of complete cycles per second.
    • ex) 60Hz = 60 cycles per second

bandwidth_frequency

  • Low Frequency Wave
    • There are many frequencies already being used by other appliances such as microwave ovens(causes interferences).
    • Small bandwidth: There is no much space not being used around it.
    • Too crowded these days.
    • Covers farther distance
    • Low speed
    • ex) Wifi (2.4GHz or 5 GHz)
  • High Frequency Wave
    • Large bandwidth: There is a lot of space not being used around it.
    • Covers short distance
    • High speed
    • ex) Millimeter Wave (60GHz)

 

Latency vs. Jitter

Screen Shot 2017-09-26 at 11.18.26 PM

Latency

  • Amount of time it takes for a packet to travel from point A to point B(or round-trip).
    • ex) Data Latency: time between a query and the result displaying on the screen.

Jitter

  • Variance in latency over time
  • If every packet takes exactly the same amout of time to travle from A to B, there is no jitter.

4 ways to handle button click

128

1. New OnClickListener in  setOnClickListener’s parameter

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("BG","1st way handling button click");
            }
        });

    }
}

2. Inner class OnClickListener

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(buttonListener);

    }

    private View.OnClickListener buttonListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("BG","2nd way handling button click");
        }
    };
}

3. Implements OnClickListener interface & override onClick()

public class MainActivity extends Activity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button) findViewById(R.id.button);
        b.setOnClickListener(this);

    }
    @Override
    public void onClick(View view) {
        switch(view.getId()){
            case R.id.button:
                Log.d("BG","3rd way handling button click");
                break;
        }
    }
}

4. Assign method at onClick attribute in layout file.

Activity class

public class MainActivity extends Activity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void buttonClick(View view) {
        Log.d("BG","4th way handling button click");
    }
}

layout file

<Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/button"
    android:onClick="buttonClick" />

 

Useful Git tips

github-mark

Apply .gitignore on already pushed repository

$ git rm -r --cached .
$ git add .
$ git commit -m '.gitignore applied'

Disconnect local repository from remote

$ git remote rm origin

 

vi Find & Replace

find_and_replace1600

Syntax

screen-shot-2016-10-20-at-12-48-14-am

Range

  • [%]
    • All lines in the file.
  • [1,30]
    • line 1 to 30
  • [5,$]
    • line 5 to last line

Pattern

  • This can be plain text and also regular expression. Combining regular expression and this command, replacing words in vi, will be powerful.
  • \<pattern\>
    • This will get the exact match, not all contained word.
This is his bag

: %s/his/her/g
=> Ther is her bag

Above command changes This also because it contains “his”.

This is his bag

: %s/\<his\>/her/g
=> This is her bag

 

Flags

  • [C]
    • Confirm each substitution
  • [g]
    • Replace all occurrence in the line
    • If you don’t put, default is just replacing first occurrence.
  • [i]
    • Ignore case for the pattern

Count

  • Do substitution in N lines from the current position of the cursor
 :s/hi/hello/g 4 

This means change all hi to hello in 4 lines from current line.

 

malloc( ) and free( )

malloc

malloc() and free()

  • allocates the requested memory and returns a pointer to it. (Dynamic memory allocation)
  • should #include<stdlib.h>
  • void *malloc(# of bytes): the function returns address of the memory.
  • void free(current_storage_pointer): de-allocate it to prevent memory leakage.

 

Example

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

int main(){
   int *p;
   p =(int *) malloc(sizeof(int));
   if(p==NULL){
      puts("Failed to allocate memory!");
   }else{
      *p = 20;
      printf("%d",*p);
      free(p);
   }
}

Example (Array)

#include<stdio.h>
#include<stdlib.h>
int main(){
   int size;
   printf("Enter the size of the array: ");
   scanf("%d", &size);
   int *a;
   a = (int *)malloc(size * sizeof(int));
   printf("\nEnter the values of the array: ");
   int i;
   for(i = 0; i < size; i++){
      scanf("%d", &a[i]);
   }
   printf("\nThe values in the array are: \n");
   for(i = 0; i < size; i++){
      printf("%d\t", a[i]);
   }
   free(a);
}

CyanogenMod

cynogenmod

CyanogenMod

  • most popular custom ROM for Android devices
  • Android Mobile Operating system-based Open Source Firmware for smartphones and tablet devices.

Why you should install CyanogenMod

  1. CyanogenMod provides you with an up-to-date version of Android. It’s also a pure, stock Android experience. If it supports your device, it will provide you with a pure, up-to-date Android experience. It’s a way to revitalize old Android devices that manufacturers are no longer updating.
  2. Privacy Guard lets you control which permissions installed apps can use, and which permissions new apps will get by default. This gives you an iOS-style permission experience on Android, so you can decide whether that app should be allowed to access your location, contacts, and other private data while still using the app.
  3. The Superuser screen integrates root permissions into Android’s Settings screen. This interface functions as a traditional way to allow and disallow superuser requests from apps, but it also allows you to enable root or disable it for your entire device.screen-shot-2016-10-02-at-6-45-38-pm
  4. The Themes panel allows you to install and choose theme packs, styles, icons, fonts, sound packs, and even boot animations to customize your device.screen-shot-2016-10-02-at-6-45-20-pm
  5. The Interface settings screen is packed with options. You can tweak the status bar, quick settings panel, notification drawer, and navigation bar. For example, you could reorder the buttons on the navigation bar at the bottom of your screen, or rearrange the order of the tiles in the quick settings panel.
  6. The DSP Manager app provides system-wide equalizer controls you can use to adjust the sound coming from your device, enabling bass boost, activating an equalizer, and selecting presets that match the music you listen to.
  7. Use the Buttons screen to control what your device’s buttons do. For example, you could long-press the volume buttons to switch music tracks. This is a great solution for skipping between songs without pulling your phone out of your pocket if you don’t have a headphone cable with an integrated remote.
  8. CyanogenMod includes profiles, which you can find under Settings > Profiles or by long-pressing the power button and tapping the Profile option. Profiles are groups of settings.

cyanogenmod-logo

Rom

  • Read Only Memory. It usually describes a piece of hardware, a memory chip that you normally can’t write to. Device manufacturers will typically use ROM to store the OS to help ensure the devices maintains a known state and is thus more reliable and easier to support.
  • pre-packaged OS with certain features added or removed, compared to the stock OS

os.system() vs. subprocess.call()

python_logo

os.system()

  • executed in a subshell, usually bash on linux and OSX, and cmd.exe on windows.
  • The shell will take the string given and interpret the escape characters.
    • ex)  os.system(“python –version”)

subprocess.call()

  • default does not use a shell – it simply tries to run an executable with a name given by string a. You actually can’t pass any arguments in the string a – only the literal name of the executable.
  • To run a command with arguments, I need to give this to subprocess.call as a list
    • ex)  subprocess.call([“python”, “–version”])

 

subprocess.call() can be used same as os.system() by setting shell to true.

  • ex)  subprocess.call(“python –version”, shell=True)

Hard Link vs. Soft Link

linkbuilding

Hard Link

Hard links are just different names for the same file.

  • One file can have many different names or hard links.
  • Both original file and link file have same Inode number(Index Number).
  • If one is modified, the other one is also modified automatically.
  • Both files’ link number increases to 2.
  • Even though original is deleted, link file works properly.
  • Form: ln originalFile linkFile

Screen Shot 2016-08-24 at 10

Soft Link (Symbolic Link)

Soft links are similar to MS windows shortcut.

  • One file can have many shortcuts pointing to it.
  • Original file and link file have Different Inode number(Index Number).
  • If one is modified, the other one is also modified automatically.
  • Link number doesn’t change.
  • If original is deleted, link file doesn’t work.
  • Form: ln -s originalFile linkFile

Screen Shot 2016-08-24 at 11