tag:blogger.com,1999:blog-20040347461112867342024-03-13T03:07:15.240+03:00Linux, Matlab, Python, Android, LatexAnonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.comBlogger42125tag:blogger.com,1999:blog-2004034746111286734.post-31896531472832964152014-02-07T08:30:00.000+02:002014-02-07T08:34:54.217+02:00Android Vibration Class Example Code How do we vibrate android phone? How should we use vibration class? If you looking for this answers look at the following link. Download full source code and see how we do it!.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://turbobit.net/i5b12ixndorn.html" target="_blank"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGh3mawpZCr5qj365UOoeYsl78lNK2j5mcoDpeMgh0Szf_zpvyZ5tj8rtElVy-pz9695cZG3wakoVNIfTmcNfPzfXSVtNObfNriZlt1WUZVaVjuSJisX23wU_sjJe8j0TihBM_kLM8cmI/s1600/android_code_download.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-78351447296305343202014-02-07T02:31:00.001+02:002014-02-08T19:45:25.832+02:00Printing Text in Java - Code Example This post contains a java code that prints a few sentences.
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<pre class="prettyprint java">import java.awt.JobAttributes;
import javax.swing.JOptionPane;
public class Main {
public static void main(String argS[]) {
System.out.println("Hello World!");
System.out.print("Welcome to Java Programming!");
System.out.println(" This is a line following above line!.");
JOptionPane.showMessageDialog(null, "Welcome to \n Java Programming!");
System.exit(0);
}
}
</pre>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-10754512567893670552014-02-07T02:27:00.000+02:002014-02-08T19:45:58.254+02:00Addition Example with Java This post contains a java code that adds two input entered by the user and show the result.
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<pre class="prettyprint java">import java.awt.JobAttributes;
import javax.swing.JOptionPane;
public class Addition {
public static void main(String args[]) {
String number1, number2;
Integer num1,num2,sum;
number1 = JOptionPane.showInputDialog("Enter first number:");
number2 = JOptionPane.showInputDialog("Enter second number:");
num1 = Integer.parseInt(number1);
num2 = Integer.parseInt(number2);
sum = num1 + num2;
JOptionPane.showMessageDialog(null, "The sum is "+sum,"Results",JOptionPane.INFORMATION_MESSAGE);
}
}
</pre>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-22207177943682223512014-02-06T08:17:00.002+02:002014-02-06T08:19:38.552+02:00Simple Alarm with Shell ScriptIn this post, we are going to develop a <b><span style="color: red;">simple alarm </span></b>with shell scripts.<br />
<br />
To get the time we use <b><span style="color: red;">date </span></b>command. To play a sound file we use <b style="color: red;">aplay </b>command-line player. It is also a recorder. Since we are developing an alarm it must control the time continuously so we need an infinite loop. Source codes are given in the following.<br />
<br />
<b>Source Codes: </b><br />
<pre class="prettyprint java">#!/bin/bash
# Purpose: Demo date command
# Author: Mustafa Demir -www.eeecoder.blogspot.com- eeecoder@gmail.com
while :
do
echo "Press [CTRL+C] to stop.."
now=$(date +"%H:%M")
echo "Current time : $now"
echo " is current time true ?"
if [ "$now" == "08:06" ]; then
echo "Yes!"
aplay sample.wav
else
echo "No!"
fi
done
</pre>
<br />
By changing the controlled time and sample.wav you can adjust it as you want.
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-34103602512025162962013-12-14T14:42:00.000+02:002013-12-14T15:04:02.246+02:00Transmission Line Analysis Using MatlabMatlab has a <b>Radio Frequency Toolbox(rf toolbox)</b>. Using this toolbox matlab allows us to do some simulation and calculations about transmission lines, active components, RLC components, black box elements etc. In this post we are going to analyze a microstripline using <b><span style="background-color: white; color: red;">'rfckt.microstrip' </span></b>class in the matlab.<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqnAO_KOQAGU5onM38YyeeTN5974GYWIi14If3Pf6rYCVEuTBE_omRfYjDeZjRDW5fWqLE5_WLL_YzEBuWckZ5BZZSrSPOxWjZCw_DBaLIRY40TrvHl_EQ7riwwXlUWlFrNFsyCbZU-Ng/s1600/MicroStrip.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqnAO_KOQAGU5onM38YyeeTN5974GYWIi14If3Pf6rYCVEuTBE_omRfYjDeZjRDW5fWqLE5_WLL_YzEBuWckZ5BZZSrSPOxWjZCw_DBaLIRY40TrvHl_EQ7riwwXlUWlFrNFsyCbZU-Ng/s320/MicroStrip.png" width="320" /></a>Let's calculate characteristic impedance of a microstrip line at 1Ghz, 2Ghz and 3Ghz with the given specifications below:<br />
<br />
thickness = 5.000e-09<br />
width = 4.000e-04<br />
height = 3.000e-04<br />
<br />
To do the given task we can write the following m file and execute it. The output of the matlab is given below the codes.<br />
<br />
<br />
<pre class="prettyprint java">% written by Mustafa DEMİR - eeecoder@gmail.com
%Dec 14, 2013
mstrpline = rfckt.microstrip('Thickness',5.000e-09,'Width',4.000e-04,'Height',3.000e-04);
analyze(mstrpline,[1e9 2e9 3e9]);
mstrpline.AnalyzedResult
getz0(mstrpline)
</pre>
<br />
<b>Matlab Command Window Output</b><b>:</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg93IMBjWit_OO9p1DQd5FPdI0dIccHvXnojVagY-ziP0qGOtZ8OZPzE67T4IpuBk89BY3fZdBfyb3OfBnnpKCiRvdIDlS_Sw3AuYTec3vkKAl8l726KMtKvubj09t3GUJB_3QFLW-9s_c/s1600/microstripline_analyze.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg93IMBjWit_OO9p1DQd5FPdI0dIccHvXnojVagY-ziP0qGOtZ8OZPzE67T4IpuBk89BY3fZdBfyb3OfBnnpKCiRvdIDlS_Sw3AuYTec3vkKAl8l726KMtKvubj09t3GUJB_3QFLW-9s_c/s1600/microstripline_analyze.png" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-79080357230710774442013-11-07T21:13:00.000+02:002013-11-07T21:21:09.326+02:00USB Not Working on Virtualbox (on Linux host)<span style="font-family: inherit; font-size: large;">When using <a href="http://www.eeecoder.blogspot.com/">Virtualbox</a>, generally we have <a href="http://www.eeecoder.blogspot.com/" target="_blank">usb problem.</a> It doesn't work at the begining. The reason of that situation is the users of virtualbox operating systems doesn't know the host user. (in this case host is any Linux distribution)</span><br />
<br />
<span style="font-family: inherit; font-size: large;">To deal with this problem we need to add host user to the <span style="color: red;">'vboxusers'</span>(virtualbox users g.) group. Proceed the following steps:</span><br />
<span style="font-family: inherit;"><span style="font-size: large;"><br /></span>
</span><span style="font-size: large;"><span style="color: #3d85c6;"><b><span style="font-family: inherit;"><span style="font-size: x-large;">1.</span></span> </b></span>Open a terminal</span><br />
<span style="font-size: large;"><span style="font-size: x-large;"><span style="color: #3d85c6;"><b>2.</b></span></span> Enter the following code.</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-family: UbuntuRegular, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</span>
<br />
<pre class="prettyprint java">sudo usermod -a -G vboxusers username</pre>
<br />
<span style="font-size: large;"></span>
<span style="font-family: inherit; font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">where username is the user you want to add.</span></span><br />
<span style="font-family: inherit; font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><br /></span></span>
<span style="font-family: inherit; font-size: large;"><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="color: #3d85c6;"><span style="font-size: x-large;"><b>3.</b></span></span> </span><span style="background-color: white; display: inline ! important; float: none; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">After you do that all you need to do is open Virtualbox and select Devices > USB > "Whatever usb device you want to add"</span></span><br />
<span style="font-size: large;"><br /></span>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-33654403956819236772013-11-07T20:26:00.000+02:002013-11-07T20:31:51.204+02:00Delta Modulation Encoder and Decoder<div style="margin-bottom: 0in;">
In Delta Modulation, the quantizer is a
1-bit (two level) quantizer with magnitudes +δ and -δ . A block
diagram of a delta modulation system is shown in following figure.
<a href="http://www.eeecoder.blogspot.com/">Delta modulation</a> transmits only one bit per sample. As seen from
block diagram, the present value is compared with the previous value
and according to sign of this difference the staircase approximated
signal is whether decreased by δ or incread by δ. δ is called
step size. By this operation the input signal is approximated with a
staircase signal. After this to indicate this decreses or increses a
zero is send for decresing by δ and a one is send for increasing by
δ.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNSpkQFOg7i8Rqm8fpAITaeJlT8DbVb8qChPZQ4pQA22v6_J4KrebSA2dgISYOGpS9iz4b1-azw_7_yExAi6sCPPdeQYKxSLSBlnPyLKmjqERYGdB9B6Jr98iSnuh3Go5ee5giaxqZdto/s1600/delta_modulation_block_diagram.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNSpkQFOg7i8Rqm8fpAITaeJlT8DbVb8qChPZQ4pQA22v6_J4KrebSA2dgISYOGpS9iz4b1-azw_7_yExAi6sCPPdeQYKxSLSBlnPyLKmjqERYGdB9B6Jr98iSnuh3Go5ee5giaxqZdto/s1600/delta_modulation_block_diagram.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="margin-bottom: 0in;">
<b><br /></b></div>
<div style="margin-bottom: 0in;">
<b>Advantages of Delta Modulation </b>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
The delta modulation has the following
advantages over PCM:
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
1. Delta modulation transmits only one
bit.
</div>
<div style="margin-bottom: 0in;">
2. The transmitter and receiver is very
simple to implement.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Disadvantages of Delta Modulation </b>
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
The following are the disadvantages of
delta modulation:
</div>
<div style="margin-bottom: 0in;">
1. Granular Noise.
</div>
<div style="margin-bottom: 0in;">
2. Over-slope noise distortion.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Delta Modulator Encoder and Decoder
Implementation and Analysis</b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
I implemented delta modulator encoder
and decoder using matlab. My matlab codes and results are given in
the below.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="margin-bottom: 0in;">
<b>Note: The required comments are given
within the code.</b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<br /></div>
<pre class="prettyprint java">clc % clear command window
clear all % clear variables
close all % close all opened figures
t=[0:0.01:1] % time matrix
m=sinc(2*pi*t) % the original signal firstly we tried with sinc function
subplot(3,1,1) % to plot following 3 figures in one window
hold on % plot on this figure
plot(m,'*black') % plotting the original signal
title('sinc function') % title of first figure as 'sinc function'
xlabel('time') % x axes label as time
ylabel('amplitude') % y axes label as amplitude
d=2*pi/100 % step size as d = 2*pi/100;
for n=1:1:100 % taking 100 samples
if n==1 % if n is equal 1 do the followings.
e(n)=m(n)
eq(n)=d*sign(e(n))
mq(n)=0; % we give its initial value as zero.
else % if n is not equal one do the followins.
e(n)=m(n)-mq(n-1) % compare the present value of original signal with the previous value of quantized signal
eq(n)=d*sign(e(n)) % multiply with d and sign of difference.
mq(n)=mq(n-1)+eq(n) % add this to the previous value of quantized signal to find the present value of it.
end % finish the inner loop
end % finish the outer loop
enData = [0]; % encoded data initial value is zero.
enData(1) = mq(1); % encoded data first value is equal fist value of quantized signal.
%%%% In this part we control the quantized values whether its increases or
%%%% decreses and we set logic 1 for increased values, we set logic 0 for
%%%% decreased values.
for i =1:99
if mq(i)</pre>
<br />
I run the above script and obtained the following results in the figures. The first figure shows a sinc function which is approximated with delta modulation technique, and the second figure shows a sinusoidal function which is approximated with delta modulation technique. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauxe64k8M77uuFhB8f_5PCBAT5tJnPdmYNG6yH647mUnLb9NcfO-zg5Oo1vy5fxxWi3WzMNa-cHltosFiAinuaxuHsYt5aejDbAUWJ4F0EAUzbh6ZlO-_ElYgT9iLify3oa9WZq6nlyI/s1600/delta_modulator_and_quantization.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="delta modulation encoder and decoder" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgauxe64k8M77uuFhB8f_5PCBAT5tJnPdmYNG6yH647mUnLb9NcfO-zg5Oo1vy5fxxWi3WzMNa-cHltosFiAinuaxuHsYt5aejDbAUWJ4F0EAUzbh6ZlO-_ElYgT9iLify3oa9WZq6nlyI/s1600/delta_modulator_and_quantization.png" title="" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-11443131803879717292013-10-10T22:11:00.000+03:002013-10-10T22:12:19.922+03:00Shared Folder on Virtualbox on Linux HostThere are a lot of people who use windows on virtualbox which is hosted by a linux distribution. For example, I installed virtualbox on Linux Mint 1.14 to setup Windows XP on it and use this for some software that I need for my education on Electrical & Electronics Engineering. Let's start with the most known problem.<br />
<br />
<b><span style="color: red;">Problem :</span></b><br />
<br />
When we use virtualbox the most important problem is that how to share folders or directories with the host and any operating systems installed on virtualbox.<br />
<br />
<b><span style="color: red;">Solution: </span></b><br />
<b><span style="color: red;"><br /></span></b>
To solve this problem just follow the given instructions below:<br />
<br />
<span style="color: #0b5394;"><span style="font-size: large;"><b><i>1. </i></b></span></span>Open virtualbox and start any os that you installed on vb.<br />
<span style="color: #0b5394; font-size: large;"><i><b>2. </b></i></span>Click 'Devices' tab which is seen in the menu bar of vb.<br />
<span style="color: #0b5394; font-size: large;"><i><b>3. </b></i></span>Select ' Install Guest Additions'<br />
<br />
If it asks to download click and proceed it.<br />
<br />
<i><b><span style="color: #0b5394; font-size: large;">4. </span></b></i>Totally close the operating system that you run on virtualbox.<br />
<span style="color: #0b5394; font-size: large;"><b><i>5. </i></b></span>On Virtualbox software, click settings.<br />
<span style="color: #0b5394; font-size: large;"><b>6.</b></span> You are going to see an option like 'Shared Folders' or 'Shared Directories'. Click on that.<br />
<b><i><span style="color: #0b5394; font-size: large;">7.</span></i></b> In that option click Add Shared Folder icon and enter its location and its name whatever you want. Make sure you checked read box before you click ok.<br />
<br />
That's it, now you can share any folder between your host and operating system installed on virtualbox.(also called Guest Operating Systems)Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com2tag:blogger.com,1999:blog-2004034746111286734.post-63277540148407700422013-08-27T22:27:00.000+03:002013-08-27T22:30:29.714+03:00Modeling a Whale Call with MatlabI did my computer probation in a company called FIGES last year. In one of these days, my job was modeling a whale call of a blue whale. To do this firstly I did a long research, because I have needed<br />
some equations to represent whale call.<br />
<br />
<b><span style="color: red;">According to my research:</span></b><br />
<b><span style="color: red;"><br /></span></b>
Befitting the largest mammal on earth, the call of an adult blue whale is loud and low The<br />
sound carries farther than any other animal sound, and can be detected over a thousand miles<br />
away. The call has a distinct pattern. An a “trill” usually precedes a series of B “moans.”<br />
There is little variation in the call among individual whales.<br />
<br />
The B call is simpler and easier to analyze. It consists of a fundamental frequency around 16-<br />
17 hertz and a series of harmonics(multiples) of the fundamental frequency. The amplitude of<br />
the call is modulated to produce a loud moan followed by weaker moan.<br />
<br />
• The envelope of the signal is treated as a decaying sine wave of the form A0*e^(-<br />
Bt)*sin(2*pi*fm*t) where the amplitude A0 the decay rate B, and the modulating<br />
frequency fm are all adjustable parameters.<br />
<br />
• The signal itself is treated as a sum of harmonics sin(2*pi*n*f0*t) for n=0,1,2,3, ... .<br />
The harmonics are assumed to be present for the entire duration of the call, even<br />
though the higher harmonics appear and disappear in the middle of the call. (Simply<br />
chopping off the higher harmonics introduces unwanted frequencies.)<br />
<br />
• Because blue whale calls are so low, they are barely audible to humans. The time scale<br />
in the data being modeled is compressed by a factor of 10 to raise the pitch and make<br />
it more clearly audible. The model works with the same “x10” audible frequencies.<br />
<br />
Using these informations I wrote the script in the following:<br />
<br />
<textarea style="background-color: #2c3539; border: 2px; color: #8afb17; height: 450px; margin: 2px; width: 595px;">%CALLMODEL Models a blue whale B call.
%Uses a model of the form y = A.*y0
%where A = A0*exp(-B*t).*sin(2*pi*fm*t)
%and y0 is a sum of harmonics
%yn = sin(2*pi*n*f0*t)
% Create the time base for the signal.
fs = 4000;
t = 0:(1/fs):1.5;
% Set the fundamental frequency of the call.
f0 = 175;
% Create the harmonics.
y0 = sin(2*pi*f0*t) + sin(2*pi*2*f0*t) + sin(2*pi*3*f0*t);
% Set the additional parameters in the model.
A0 = 2; % Initial amplitude.
B = 1.5; % Amplitude decay rate.
fm = 0.65; % Frequency of the modulating envelope.
% Create the envelope
A = A0*exp(-B*t).*sin(2*pi*fm*t);
% Create the call.
call = A.*y0;
% Plot the model call and listen to it.
figure
plot(t,call)
xlabel('Time')
ylabel('Amplitude')
title('{\bf Blue Whale B Call Model}')
soundsc(call,fs)
</textarea><br />
<br />
<span style="color: red;"><b>The Blue Whale B call model</b></span> is shown in following figure. If you also wanna hear the voice, write down the codes into a matlab mfile and run it..<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoAxbp-t8TRZLyMaSXvNi17vm0sjzQZ0j4fnE3GSl8AXIGje2snrnOKLSEVojD33RzHX3IVKOMws0dNzhELPT-7omPDAp7uXjILH4fvhwvJfLDY4I81srvkoMRy6qKfzTczAhxhdGq8bg/s1600/blue_whale_call_matlab.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoAxbp-t8TRZLyMaSXvNi17vm0sjzQZ0j4fnE3GSl8AXIGje2snrnOKLSEVojD33RzHX3IVKOMws0dNzhELPT-7omPDAp7uXjILH4fvhwvJfLDY4I81srvkoMRy6qKfzTczAhxhdGq8bg/s1600/blue_whale_call_matlab.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-80199781168686610292013-08-21T23:46:00.000+03:002013-08-28T07:35:04.046+03:00Firefox Babylon Add-on and MoreEveryone knows Babylon dictionary, it is one of the most common dictionary that used in the world. A free babylon extension for firefox is available <a href="https://addons.mozilla.org/en-US/firefox/addon/babylon-dictionary-word-search/?src=api">here</a>. It works quite enough, the requirement is just clicking the word that you wanna search twice.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6ngklmtZ9je_k31iivcw_A6CD_igYkfHfYFGBcCnQDFD_dsdlDZmT53fxriisKU5VhUR6gIVnZNZrqKgOXZV2cPr9s0XKGXnmkRg1BJRwFnJh-7Bzp9ogGdRBtBF9qRPro9x6Ig4n7O8/s1600/what+is+babylon.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6ngklmtZ9je_k31iivcw_A6CD_igYkfHfYFGBcCnQDFD_dsdlDZmT53fxriisKU5VhUR6gIVnZNZrqKgOXZV2cPr9s0XKGXnmkRg1BJRwFnJh-7Bzp9ogGdRBtBF9qRPro9x6Ig4n7O8/s400/what+is+babylon.png" width="390" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Babylon Dictionary</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b><span style="color: red;">But missing part is that:</span></b></div>
<div class="separator" style="clear: both; text-align: left;">
<b><span style="color: red;"><br /></span></b></div>
<div class="separator" style="clear: both; text-align: left;">
It doesn't save the word you search once. When you encounter a word that you have searched 10 days ago, you need to remember it or you need to search it again in a dictionary. </div>
<br />
<b><span style="color: red;">SOLUTION:</span></b><br />
<b><span style="color: red;"><br /></span></b>
I modified the babylon extension to resolve this deficiency. When you use the modified version, you will find the words you searched before in a file called mywords.html which is going to be found in your desktop. The mywords.html will looking as in the following picture. :)<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuOQVTR0wn_orSDlDNc1IPurCwNFCn57RGCbFpPIkEIE1hGyf4AfkRtwaBYhT3D7ffm2-cf4TWcqvbZJsc5y-Co6AY4h33YONJ19EXsVmiJS47NwiFOCJyXS1_zaTftr_wTP63I35_mNo/s1600/babylon.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuOQVTR0wn_orSDlDNc1IPurCwNFCn57RGCbFpPIkEIE1hGyf4AfkRtwaBYhT3D7ffm2-cf4TWcqvbZJsc5y-Co6AY4h33YONJ19EXsVmiJS47NwiFOCJyXS1_zaTftr_wTP63I35_mNo/s1600/babylon.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Babylon - mywords.html<br />
<br />
<div style="text-align: left;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: left;">
</div>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><script type="text/javascript"><!--
google_ad_client = "ca-pub-9384858954425908";
/* eeecoder_main_Blog1_300x250_as */
google_ad_slot = "1643465871";
google_ad_width = 300;
google_ad_height = 250;
//</script>
</td></tr>
</tbody></table>
-->
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>
<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9384858954425908";
/* eeecoder_main_Blog1_300x250_as */
google_ad_slot = "1643465871";
google_ad_width = 300;
google_ad_height = 250;
//</script>
<br />
<br />
Watch the following video tutorial to setup the babylon to do the work we want :)<br />
<div class="separator" style="clear: both; text-align: left;">
[By the way, the blog you see in the video is belongs to my bro. <a href="http://make-possible.blogspot.com/">http://make-possible.blogspot.com</a>]</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<iframe allowfullscreen="" frameborder="0" height="390" src="http://www.youtube.com/embed/i84fQAp_KB8" width="640"></iframe><br />
<br />
Download the modified version from <a href="https://dl.dropboxusercontent.com/u/44911226/babylon/%7Ba27007d0-bec0-4df7-abf8-54ae0b833ce8%7D.xpi">here</a> and <a href="https://dl.dropboxusercontent.com/u/44911226/babylon/mywords.html">mywords.html</a>(right click and save it). Install the extension to the firefox and copy mywords.html into your desktop. Also you can use the following code to download mywords.html into your desktop:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 96px; margin: 2px; width: 733px;">mkdir ~/Desktop; wget https://dl.dropboxusercontent.com/u/44911226/babylon/mywords.html -O ~/Desktop/mywords.html
</textarea><br />
<br />
Use it with fun :).<br />
<br />
<b><span style="color: red;">What I changed in Babylon to be able to do this? (saving every word we searched once)</span></b><br />
<b><span style="color: red;"><br /></span></b>
The changes I have made are given in the following:<br />
<br />
I add a new function called <b>saveDataToFile</b> into javascript file <b>BabylonWordSearch.Results.js. </b>The function is given below:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 462px; margin: 2px; width: 656px;">saveDataToFile: function(filepath, data, charset)
{
var lokasyon = data.search("OT_CopyrightStyle") - 14;
var lokasyon2 = data.search("Download this dictionary") + 37;
//alert(lokasyon);
data = data.substr(lokasyon2,lokasyon-lokasyon2);
data = data +"
";
file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filepath);
// file is nsIFile, data is a string
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream);
// use 0x02 | 0x10 to open file for appending.
foStream.init(file, 0x02 | 0x10, 0666, 0);
// write, create, truncate
// In a c file operation, we have no need to set file mode with or operation,
// directly using "r" or "w" usually.
// if you are sure there will never ever be any non-ascii text in data you can
// also call foStream.write(data, data.length) directly
var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Components.interfaces.nsIConverterOutputStream);
converter.init(foStream, "UTF-8", 0, 0);
converter.writeString(data);
converter.close(); // this closes foStream
}
</textarea>
<br />
<br />
In if block that I given below, I send the answer that I get from babylon server by innerHTML to the above function(<b>saveDataToFile</b>) .<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 121px; margin: 2px; width: 656px;">if (containerDiv) {
var data = this.resultsFrame.contentWindow.document.getElementById('container').innerHTML;
this.saveDataToFile("~/Desktop/mywords.html",data,"UTF-8");
</textarea><br />
<br />
To modify the extension yourself, you can find its source code from that <a href="http://programlama.wordpress.com/2013/08/10/macosx-theme-eklentisini-desteklemedigi-yeni-firefox-surumlerine-yuklemek/">post.</a><br />
<br />
<b><span style="color: red;">If you have any question or need some help, leave a comment below.</span></b><br />
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com4tag:blogger.com,1999:blog-2004034746111286734.post-42875112001727984212013-08-19T17:55:00.000+03:002013-08-19T18:22:26.201+03:00Loops in Matlab ( for in matlab, while matlab, for matlab)There are two loops in matlab:<br />
<ul>
<li>For loops </li>
<li>While loops</li>
</ul>
<div>
For loops are used when the number of loop is certain whereas while loops are used when the condition is specified for a loop to terminate the code in it. </div>
<div>
<br /></div>
<div>
You can see the usage form of for loops and while loops from given examples below:</div>
<div>
<br /></div>
<div>
Example 1: For loop<br />
<br /></div>
<textarea style="background-color: #2c3539; color: #8afb17; height: 68px; margin: 2px; width: 344px;">for i=1:4,
i
end
</textarea><br />
<br />
Example 2: While loop<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 99px; margin: 2px; width: 409px;">a=0;
while(a<10)
a= a+1;
a
</textarea><br />
<br />
For information in detail type in command window:<br />
<br />
'help for' to get the following result:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 515px; margin: 2px; width: 645px;"> for Repeat statements a specific number of times.
The general form of a for statement is:
for variable = expr, statement, ..., statement END
The columns of the expression are stored one at a time in
the variable and then the following statements, up to the
END, are executed. The expression is often of the form X:Y,
in which case its columns are simply scalars. Some examples
(assume N has already been assigned a value).
for R = 1:N
for C = 1:N
A(R,C) = 1/(R+C-1);
end
end
Step S with increments of -0.1
for S = 1.0: -0.1: 0.0, do_some_task(S), end
Set E to the unit N-vectors
for E = eye(N), do_some_task(E), end
Long loops are more memory efficient when the colon expression appears
in the for statement since the index vector is never created.
The BREAK statement can be used to terminate the loop prematurely.
See also parfor, if, while, switch, break, continue, end, colon.
Reference page in Help browser
doc for
</textarea><br />
<br />
or you can type doc for to get reference page in help browser. I am not giving it here.<br />
<br />
For while loops you can type:<br />
<br />
'help while' to get information in detail like as given below:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 443px; margin: 2px; width: 647px;">>> help while
while Repeat statements an indefinite number of times.
The general form of a while statement is:
while expression
statements
END
The statements are executed while the real part of the expression
has all non-zero elements. The expression is usually the result of
expr rop expr where rop is ==, <, >, <=, >=, or ~=.
The BREAK statement can be used to terminate the loop prematurely.
For example (assuming A already defined):
E = 0*A; F = E + eye(size(E)); N = 1;
while norm(E+F-E,1) > 0,
E = E + F;
F = A*F/N;
N = N + 1;
end
See also for, if, switch, break, continue, end.
Reference page in Help browser
doc while
</textarea><br />
<br />
or you can type 'doc while' to get reference page in help browser. I am not giving it here.<br />
<br />
<b><span style="color: #990000;">If you have any question or need some help, leave a comment below.</span></b><br />
<b><span style="color: #990000;"><br /></span></b>Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-24864244067208821092013-08-18T06:16:00.000+03:002014-02-08T19:24:56.977+02:00Flash for Linux
Hi guys, most of the linux distributions do not include flash as default installed software. Mint comes with flash but such as in ubuntu it is not preinstalled. So we have to install it. There are a few ways to install flash in linux:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhetMnFIHiMliA2fqhEgODV3xUzBq_J61aJf4BYXZgyJbjkWI0g9wUy4vyMrgNpnrHbQ6SxNNUkoqVPnbLtSyb0pAe_9IGgOBu5We4mEQwF41A3cK-trv8Ja8f7nB08WyD9ZZjscXNwTqg/s1600/linux+flash.jpeg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhetMnFIHiMliA2fqhEgODV3xUzBq_J61aJf4BYXZgyJbjkWI0g9wUy4vyMrgNpnrHbQ6SxNNUkoqVPnbLtSyb0pAe_9IGgOBu5We4mEQwF41A3cK-trv8Ja8f7nB08WyD9ZZjscXNwTqg/s1600/linux+flash.jpeg" title="linux flash" /></a></div>
<i><span style="color: #0b5394;"><span style="font-size: large;"><b>1.</b></span></span></i> - open software center<br />
- enter 'adobe flashplugin<br />
-click install, that's it. (That is the first way to get linux flash)<br />
<br />
<b><span style="font-size: large;"><span style="color: #0b5394;"><i>2.</i></span></span></b> - open terminal by typing Ctrl+F2<br />
- write the following code:<br />
<br />
to install adobe flash on<b> ubuntu:</b><br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 42px; margin: 2px; width: 397px;"> $ sudo apt-get install flashplugin-nonfree</textarea><br />
<br />
to install adobe flash on <b>mint:</b><br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 42px; margin: 2px; width: 397px;"> $ sudo apt-get install mint-flashplugin</textarea><br />
<br />
- after this, if it ask Y or N type Y. Flash is installed, you can try it now. (That is the second way yo get linux flash)<br />
<br />
<i><span style="color: #0b5394;"><span style="font-size: large;"><b> 3.</b></span></span></i> - Open any website that requires flash, like youtube. It will ask you 'install missing plugins' press install or download. That should solve your problem about flash plugin. (That is the third way to get linux flash)<br />
<br />
<span style="color: #0b5394; font-size: large; font-style: italic; font-weight: bold;">4. </span>-Open software center<br />
- type adobe flash into search box<br />
-click install, that's it. (that is the fourth way to get flash on linux)<br />
<br />
<span style="color: red;"><b>If you have any question or need some help, leave a comment below.</b></span><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-66664484099595260602013-08-12T21:16:00.002+03:002013-08-14T17:15:48.032+03:00Flashlight Android ApplicationHi guys, today I wanna tell about one of my experince on android app development. A couple of days ago, I wrote a Flashlight android app using docs in developer.android.com, I checked the app in two different phones:<br />
<br />
<ul>
<li><b>first in a Motorola phone:</b> my app worked perfect, it did its job. (turning on and turning off flash of the camera)</li>
<li><b>second in a Samsung SIII Mini:</b> my app didn't work, it didn't do its job. (when I touched the 'open flash' button, flash couldn't open.)</li>
</ul>
<br />
So, I started to search the problem. There were a lot of statements in websites like that: "<span style="color: red;">FLASH_MODE_TORCH doesn't work on samsung</span>". I have used this parameter in my app too. I didn't believe that, because when I request possible parameters from eclipse by pressing Cntrl+Enter there was only one parameter which can open the flash: <span style="color: red;">FLASH_MODE_TORCH</span>. So, I thought there must be a missing code which requires in samsung phones and not needs in phones like Motorola. I continued to search and found a nice solution which says use "<span style="color: red;">camera.startPreview()</span>" after setting parameters of the camera. I used this in my app and it worked in samsung phones too.<br />
<br />
The picture of my app are given in the following, and you can download it from the link below pic. I wrote the app just for an example, so its gui is really bad and simple.<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk872RsYC07iLHrJnXLOewlJK47k0UwKFOmVf3oTTgfV98n76vGgsfsrUlKDXF8P4TEXVOOsa36RkCbDa-upYPEdG-3Z7ClHNvlFp7mvjMiPn08LjiEQDWKRD9st37YRrhqxoP-h2myU4/s1600/flashlight-myflash.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjk872RsYC07iLHrJnXLOewlJK47k0UwKFOmVf3oTTgfV98n76vGgsfsrUlKDXF8P4TEXVOOsa36RkCbDa-upYPEdG-3Z7ClHNvlFp7mvjMiPn08LjiEQDWKRD9st37YRrhqxoP-h2myU4/s320/flashlight-myflash.png" width="189" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://onlytest123.googlecode.com/files/MyFlash.apk"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjup-B-yoUuLUaLiS28IqsmqAZBeub62tF1sbLGARqEMr2TbFnK8NC_WdKLMV3iXXXCJ8dZ7-XgrY2-e5UDEnA766sLvEti7pDNUP2lIqC5hKkSW_SGi3-fbbM5BR9xbiR4EJK_TpvIrbo/s1600/flashlight-download.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="background-color: white; color: #333333; font-family: 'Apple Garamond'; font-size: 16px; text-align: left;"><span style="color: red;"><br /></span></b></div>
<div class="separator" style="clear: both; text-align: left;">
<b style="background-color: white; color: #333333; font-family: 'Apple Garamond'; font-size: 16px;"><span style="color: red;">If you like this article, use the share buttons below to help my blog.</span></b></div>
<b style="background-color: white; color: #333333; font-family: 'Apple Garamond'; font-size: 16px;"><span style="color: red;">If you have any question or need some help, leave a comment below.</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0Turkey38.963745 35.24332200000003538.963745 35.243322000000035 38.963745 35.243322000000035tag:blogger.com,1999:blog-2004034746111286734.post-44930625906714491282013-08-10T23:16:00.000+03:002013-08-10T23:17:08.297+03:00Initial Arrangement Example in Matlab<textarea style="background-color: #2c3539; color: #8afb17; height: 300px; margin: 2px; width: 572px;">str2=input('','s');<br />
if strmatch('do the arrangements\n',str2)<br />
<br />
disp('Yes Sir')<br />
end<br />
<br />
<br />
cd 'path'<br />
winopen('path');<br />
fprintf('Welcome to Matlab, Mr. 'name'\nCurrent Directory is rearranged, and the mlbe file is opened.\n');<br />
<br />
str1=input('','s');<br />
if strmatch('thanks',str1)<br />
disp('You are Welcome');<br />
clear;<br />
end
</textarea>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-22643326204726510432013-08-10T23:09:00.001+03:002013-08-10T23:16:39.413+03:00A Traveling Wave by Making an Animation in MATLAB <textarea style="background-color: #2c3539; color: #8afb17; height: 460px; margin: 2px; width: 639px;">clc %clears the command window<br />
clear %clears variables<br />
%Variables:<br />
%Eo wave amplitude (V/m)<br />
%f frequency (Hz)<br />
%omega angular frequency (rad/s)<br />
%t time snapshot<br />
%c speed of light<br />
%z position<br />
%E Electric Field Intensity<br />
%B phase constant (1/m)<br />
%phi phase constant (s)<br />
%phir phase constant (radians)<br />
%lambda wavelength<br />
(m)<br />
%Initial Values of Variables:<br />
f=1000;<br />
phi=0;<br />
c=2.998e8;<br />
lambda=c/f;<br />
t=1;<br />
phir=phi*pi/180;<br />
Eo=1;<br />
B=2*pi/lambda;<br />
omega=2*pi*f;<br />
z=0:4*lambda/100:4*lambda;<br />
E=Eo*cos(omega*t-B*z+phir);<br />
plot(z,E)<br />
axis([0 4*lambda -2*Eo 2*Eo])<br />
grid<br />
xlabel('z(m)')<br />
ylabel('E(V/m)')<br />
pause<br />
t=0:1/(40*f):1/f;<br />
for n=1:40;<br />
E=Eo*cos(omega*t(n)-B*z+phir);<br />
plot(z,E)<br />
axis([0 4*lambda -2*Eo 2*Eo])<br />
grid<br />
title('General Wave Equation');<br />
xlabel('z(m)');<br />
ylabel('E(V/m)');<br />
M(:,1)=getframe;<br />
end
</textarea>
<br />
<br />
After that I run it from the command window. I give three figures these are in different time to<br />
see properly the wave is travelling.<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Oz2da6GeU_E/URlfCSaA3dI/AAAAAAAAAFk/UAfuteN13Lk/s1600/3.jpg.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="260" src="http://3.bp.blogspot.com/-Oz2da6GeU_E/URlfCSaA3dI/AAAAAAAAAFk/UAfuteN13Lk/s320/3.jpg.jpeg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-jJYkZplpV0E/URlfCWZeOaI/AAAAAAAAAFo/ObZs5t8aEIs/s1600/2.jpg.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="http://2.bp.blogspot.com/-jJYkZplpV0E/URlfCWZeOaI/AAAAAAAAAFo/ObZs5t8aEIs/s320/2.jpg.jpeg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-PbnzIlxMGTM/URlfCZYZCNI/AAAAAAAAAFs/gZ0supanwqQ/s1600/1.jpg.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="http://3.bp.blogspot.com/-PbnzIlxMGTM/URlfCZYZCNI/AAAAAAAAAFs/gZ0supanwqQ/s320/1.jpg.jpeg" width="320" /></a></div>
<div>
<br /></div>
<br />
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-74168435944588195342013-08-10T23:01:00.000+03:002013-08-10T23:16:49.244+03:00How to add Categories to BloggerGuys, today I will tell about categories in blogger. Unfortunately there is no any category widget in blogger. So we have to create it by ourselves. To do this We have two solutions.<br />
<br />
<b><span style="color: red; font-size: large;">First Solution:</span></b> We can use labels with Links widget. Let me Explain with an example let’s say We want Matlab,Linux,Apple as our site’s categories. Then we need to add these names as labels to our posts.
Then by clicking the labels in Labels widget we get their URLs. Copy these URLs one by one and add them to Links widget. In that way, we have categories in our blog. Have fun...<br />
<br />
<span style="color: red; font-size: large;"><b>Second Solution: </b></span>We can use laves with HTML/JAVASCRIPT widget. This time we will modify or create our Links widget by ourselves via writing html codes into HTML/JAVASCRIPT widget. The advantage of this solution is creating original categories with your requests. I hope it helps..Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com2tag:blogger.com,1999:blog-2004034746111286734.post-76507212624001036182013-08-07T12:44:00.004+03:002014-02-08T19:50:50.227+02:00CPU Temperature Alarm System Hi, I want to write about Cpu Temperature Alarm System I have done by using advantages of linux kernel and linux shell. (I used bash shell in my script by the way.)<br />
<br />
One of the biggest advantages of linux is to reach hardware components easily through kernel. The communication with hardware comes true as given in the following steps:<br />
<br />
<span style="color: red; font-size: large; font-weight: bold;">1. </span>User writes his/her request as codes.<br />
<span style="color: red; font-size: large; font-weight: bold;">2. </span>Shell converts these codes to be understand by kernel.<br />
<span style="font-size: large; font-weight: bold;"><span style="color: red;">3.</span> </span>Kernel is a gui which can thought as an interface between hardware and shell. Kernel sends these requests to hardware components.<br />
<br />
You can understand these simple steps and more from the following scheme:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihyphenhyphenrJI7MwVnMM8v-NH_LdU-DSHaHZCRd5xnADMtYYETZ7WRm5gDHFW4ZZllfHuH2bmPn9Kjkq8iPymSGjcEB52lAEUWGHWq9DDSHjfG5qkSLcrhXaGlayQzfGOiKQyOs-XavtGyVXn14g/s1600/download.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihyphenhyphenrJI7MwVnMM8v-NH_LdU-DSHaHZCRd5xnADMtYYETZ7WRm5gDHFW4ZZllfHuH2bmPn9Kjkq8iPymSGjcEB52lAEUWGHWq9DDSHjfG5qkSLcrhXaGlayQzfGOiKQyOs-XavtGyVXn14g/s1600/download.jpg" /></a></div>
I wrote down the following script which can control cpu temperature and if it is out of the condition I have determined, it plays an alarm.<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 227px; margin: 2px; width: 453px;"># Writen by Mustafa DEMİR--http://eeecoder.blogspot.com
var=$(acpi -t | awk '{print $4}')
echo "cpu temperature: " + "$var"
if test $var < 90
then
echo "no dangere.";
else
echo "cpu is in dangere!";
play snall.wav;
fi
</textarea>
<br />
<br />
The comments about the script are given in the following step by step:<br />
<br />
<b><span style="color: red; font-size: large;">1. </span></b>I used acpi package to get temperature of cpu from sensors. Info: acpi - Shows battery status and other ACPI information<br />
<span style="color: red; font-size: large;"><b>2.</b></span> To edit the output of acpi -t command and get the cpu temperature only, I used gawk package. Info: gawk - pattern scanning and processing language<br />
<span style="color: red; font-size: large;"><b>3.</b></span> I wrote the cpu temperature with echo<br />
<span style="color: red; font-size: large;"><b>4.</b></span> I used an if-else-fi block for control part.<br />
<span style="color: red; font-size: large;"><b>5. </b></span>If it is lower than 90 C, I wrote down the message: "no dangere."<br />
<span style="color: red; font-size: large;"><b>6.</b></span> If it is higher than 90 C, I wrote down the message: "cpu is in dangere!" and play the alarm.<br />
<br />
<b><span style="color: red;">If you like this article, use the share buttons below to help my blog.</span></b><br />
<b><span style="color: red;">If you have any question or need some help, leave a comment below.</span></b><br />
<b><span style="color: red;"><br /></span></b>
<span style="font-size: x-small;">SPONSOR</span><br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9384858954425908";
/* eeecoder_main_Blog1_300x250_as */
google_ad_slot = "1643465871";
google_ad_width = 300;
google_ad_height = 250;
//</script>
-->
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script>Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-89380322778214663602013-08-05T00:22:00.001+03:002013-08-05T00:38:26.042+03:00Tuning Processes<div style="margin-bottom: 0cm;">
<b>Introduction </b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
In
real-time systems some processes can cause huge problems, or slowing
down the system performance. In such situations we need to tune the
running processes. With tuning I mean stopping or killing the
process. To be able to do this and to know when we need to know what
processes currently runnig and when process start up? Especially,
administrators need this. Because unexpected processes needs to be
down or stop in systems such as servers, gaming boxes or other
real-time systems. By saying processes I mean all applications and
services in the system. So after that we need to view the running
processes, let's look at that.</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b>Viewing Running Processes
</b>
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
The
only thing that consume your system resources are running processes.
If your computer seems to be running slower than normal, then it is
probably because of some misbehaving running processes or some
running processes that use more than resources our system have.
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
There a
couple of ways to view running processes, these are:<br />
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="color: red;"> 1.</span> top</b> command: this command lists all running processes by ordering them cpu usage and memory usages.<br />
<b><span style="color: red;"> 2.</span> ps -ef</b> command: this command lists every running processes in full detail.<br />
<b><span style="color: red;"> 3.</span></b> The Graphical System Monitor(System<span style="font-family: Times New Roman, serif;">►</span><span style="font-family: Times New Roman, serif;">Administration</span><span style="font-family: Times New Roman, serif;">►System Monitor)</span>: also enables you to list all the running processes.<br />
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b>Sample listing of running
processes from ps-ef command:</b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<textarea style="background-color: #2c3539; color: #8afb17; height: 221px; margin: 2px; width: 660px;">mustafa@mustafa-Lenovo-G550 ~ $ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Ağu04 ? 00:00:00 /sbin/init
root 2 0 0 Ağu04 ? 00:00:00 [kthreadd]
root 3 2 0 Ağu04 ? 00:00:00 [ksoftirqd/0]
root 6 2 0 Ağu04 ? 00:00:00 [migration/0]
root 7 2 0 Ağu04 ? 00:00:00 [watchdog/0]
root 8 2 0 Ağu04 ? 00:00:00 [migration/1]
root 10 2 0 Ağu04 ? 00:00:02 [ksoftirqd/1]
root 11 2 0 Ağu04 ? 00:00:00 [watchdog/1]
root 12 2 0 Ağu04 ? 00:00:00 [cpuset]
root 13 2 0 Ağu04 ? 00:00:00 [khelper]
root 14 2 0 Ağu04 ? 00:00:00 [kdevtmpfs]
root 15 2 0 Ağu04 ? 00:00:00 [netns]
root 17 2 0 Ağu04 ? 00:00:00 [sync_supers]
root 18 2 0 Ağu04 ? 00:00:00 [bdi-default]
root 19 2 0 Ağu04 ? 00:00:00 [kintegrityd]
root 20 2 0 Ağu04 ? 00:00:00 [kblockd]
root 22 2 0 Ağu04 ? 00:00:00 [ata_sff]
root 23 2 0 Ağu04 ? 00:00:00 [khubd]
root 24 2 0 Ağu04 ? 00:00:00 [md]
root 25 2 0 Ağu04 ? 00:00:00 [kworker/0:2]
root 26 2 0 Ağu04 ? 00:00:01 [kworker/1:1]
root 27 2 0 Ağu04 ? 00:00:00 [khungtaskd]
root 28 2 0 Ağu04 ? 00:00:00 [kswapd0]
root 29 2 0 Ağu04 ? 00:00:00 [ksmd]
root 30 2 0 Ağu04 ? 00:00:00 [khugepaged]
root 31 2 0 Ağu04 ? 00:00:00 [fsnotify_mark]
root 32 2 0 Ağu04 ? 00:00:00 [ecryptfs-kthrea]
root 33 2 0 Ağu04 ? 00:00:00 [crypto]
root 42 2 0 Ağu04 ? 00:00:00 [kthrotld]
root 44 2 0 Ağu04 ? 00:00:00 [scsi_eh_0]
root 45 2 0 Ağu04 ? 00:00:00 [scsi_eh_1]
root 46 2 0 Ağu04 ? 00:00:00 [scsi_eh_2]
root 47 2 0 Ağu04 ? 00:00:00 [scsi_eh_3]
root 48 2 0 Ağu04 ? 00:00:00 [scsi_eh_4]
root 51 2 0 Ağu04 ? 00:00:00 [kworker/u:4]
root 52 2 0 Ağu04 ? 00:00:00 [kworker/u:5]
root 54 2 0 Ağu04 ? 00:00:00 [kworker/1:2]
root 55 2 0 Ağu04 ? 00:00:00 [binder]
root 75 2 0 Ağu04 ? 00:00:00 [deferwq]
root 76 2 0 Ağu04 ? 00:00:00 [charger_manager]
root 77 2 0 Ağu04 ? 00:00:00 [devfreq_wq]
root 235 2 0 Ağu04 ? 00:00:00 [jbd2/sda2-8]
root 236 2 0 Ağu04 ? 00:00:00 [ext4-dio-unwrit]
root 256 2 0 Ağu04 ? 00:00:00 [flush-8:0]
root 333 1 0 Ağu04 ? 00:00:00 upstart-udev-bridge --daemon
root 335 1 0 Ağu04 ? 00:00:00 /sbin/udevd --daemon
root 411 2 0 Ağu04 ? 00:00:00 [kpsmoused]
root 459 335 0 Ağu04 ? 00:00:00 /sbin/udevd --daemon
root 460 335 0 Ağu04 ? 00:00:00 /sbin/udevd --daemon
root 535 2 0 Ağu04 ? 00:00:00 [hd-audio0]
root 633 1 0 Ağu04 ? 00:00:00 smbd -F
102 651 1 0 Ağu04 ? 00:00:00 dbus-daemon --system --fork
root 659 633 0 Ağu04 ? 00:00:00 smbd -F
root 674 1 0 Ağu04 ? 00:00:00 /usr/sbin/modem-manager
root 682 1 0 Ağu04 ? 00:00:00 /usr/sbin/bluetoothd
root 703 1 0 Ağu04 ? 00:00:00 NetworkManager
syslog 706 1 0 Ağu04 ? 00:00:00 rsyslogd -c5
root 711 2 0 Ağu04 ? 00:00:00 [krfcommd]
root 718 1 0 Ağu04 ? 00:00:00 /usr/lib/policykit-1/polkitd --n
avahi 729 1 0 Ağu04 ? 00:00:00 avahi-daemon: running [mustafa-L
avahi 732 729 0 Ağu04 ? 00:00:00 avahi-daemon: chroot helper
root 745 1 0 Ağu04 ? 00:00:00 /usr/sbin/cupsd -F
root 751 1 0 Ağu04 ? 00:00:00 upstart-socket-bridge --daemon
root 755 1 0 Ağu04 ? 00:00:00 /sbin/wpa_supplicant -B -P /run/
root 1031 1 0 Ağu04 tty4 00:00:00 /sbin/getty -8 38400 tty4
root 1037 1 0 Ağu04 tty5 00:00:00 /sbin/getty -8 38400 tty5
root 1046 1 0 Ağu04 tty2 00:00:00 /sbin/getty -8 38400 tty2
root 1047 1 0 Ağu04 tty3 00:00:00 /sbin/getty -8 38400 tty3
root 1057 1 0 Ağu04 tty6 00:00:00 /sbin/getty -8 38400 tty6
root 1071 1 0 Ağu04 ? 00:00:00 acpid -c /etc/acpi/events -s /va
root 1072 1 0 Ağu04 ? 00:00:00 cron
daemon 1073 1 0 Ağu04 ? 00:00:00 atd
root 1179 1 0 Ağu04 ? 00:00:00 /usr/sbin/mdm
root 1180 1179 0 Ağu04 ? 00:00:00 /usr/sbin/mdm
root 1215 1180 2 Ağu04 tty8 00:00:18 /usr/bin/X :0 -audit 0 -auth /va
root 1366 1 0 Ağu04 tty1 00:00:00 /sbin/getty -8 38400 tty1
root 1377 703 0 Ağu04 ? 00:00:00 /sbin/dhclient -d -4 -sf /usr/li
nobody 1381 703 0 Ağu04 ? 00:00:00 /usr/sbin/dnsmasq --no-resolv --
root 1534 1 0 Ağu04 ? 00:00:00 nmbd -D
root 1551 1 0 Ağu04 ? 00:00:00 /usr/sbin/console-kit-daemon --n
mustafa 1624 1180 0 Ağu04 ? 00:00:00 x-session-manager
mustafa 1696 1624 0 Ağu04 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus
mustafa 1699 1 0 Ağu04 ? 00:00:00 /usr/bin/dbus-launch --exit-with
mustafa 1700 1 0 Ağu04 ? 00:00:00 //bin/dbus-daemon --fork --print
mustafa 1705 1 0 Ağu04 ? 00:00:00 /usr/lib/MateConf/mateconfd-2
mustafa 1713 1 0 Ağu04 ? 00:00:00 /usr/bin/mate-keyring-daemon --s
mustafa 1716 1 0 Ağu04 ? 00:00:00 /usr/bin/mate-settings-daemon
mustafa 1722 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfsd
mustafa 1726 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs//gvfsd-fuse -f /ru
mustafa 1736 1 0 Ağu04 ? 00:00:00 /usr/bin/pulseaudio --start --lo
rtkit 1738 1 0 Ağu04 ? 00:00:00 /usr/lib/rtkit/rtkit-daemon
mustafa 1741 1736 0 Ağu04 ? 00:00:00 /usr/lib/pulseaudio/pulse/gconf-
mustafa 1743 1 0 Ağu04 ? 00:00:00 /usr/lib/x86_64-linux-gnu/gconf/
mustafa 1745 1624 0 Ağu04 ? 00:00:01 marco
mustafa 1749 1624 0 Ağu04 ? 00:00:01 mate-panel
mustafa 1751 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfs-udisks2-volum
root 1755 1 0 Ağu04 ? 00:00:00 /usr/lib/udisks2/udisksd --no-de
mustafa 1762 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volum
mustafa 1766 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-mo
mustafa 1770 1624 0 Ağu04 ? 00:00:04 caja
mustafa 1773 1624 0 Ağu04 ? 00:00:00 /usr/lib/polkit-mate/polkit-mate
mustafa 1774 1624 0 Ağu04 ? 00:00:00 mate-volume-control-applet
mustafa 1776 1624 0 Ağu04 ? 00:00:00 mate-bluetooth-applet
mustafa 1778 1 0 Ağu04 ? 00:00:00 /usr/lib/matecomponent/matecompo
mustafa 1784 1624 0 Ağu04 ? 00:00:00 nm-applet
mustafa 1787 1624 0 Ağu04 ? 00:00:00 /usr/bin/python /usr/share/syste
mustafa 1788 1624 0 Ağu04 ? 00:00:00 /usr/bin/python /usr/bin/mintupd
mustafa 1789 1624 0 Ağu04 ? 00:00:00 mate-power-manager
mustafa 1792 1788 0 Ağu04 ? 00:00:00 sh -c /usr/lib/linuxmint/mintUpd
mustafa 1793 1792 0 Ağu04 ? 00:00:00 python /usr/lib/linuxmint/mintUp
mustafa 1808 1 0 Ağu04 ? 00:00:00 mate-screensaver
mustafa 1815 1 0 Ağu04 ? 00:00:01 python /usr/lib/linuxmint/mintMe
mustafa 1817 1 0 Ağu04 ? 00:00:02 /usr/lib/mate-panel/wnck-applet
mustafa 1821 1 0 Ağu04 ? 00:00:01 /usr/lib/mate-sensors-applet/mat
mustafa 1823 1 0 Ağu04 ? 00:00:00 /usr/lib/mate-panel/clock-applet
mustafa 1825 1 0 Ağu04 ? 00:00:00 /usr/lib/mate-panel/notification
root 1833 1 0 Ağu04 ? 00:00:00 /usr/lib/upower/upowerd
mustafa 1854 1 0 Ağu04 ? 00:00:00 /usr/lib/at-spi2-core/at-spi-bus
mustafa 1861 1854 0 Ağu04 ? 00:00:00 /bin/dbus-daemon --config-file=/
mustafa 1887 1 0 Ağu04 ? 00:00:00 /usr/lib/at-spi2-core/at-spi2-re
root 2000 1 0 Ağu04 ? 00:00:00 /usr/lib/udisks/udisks-daemon
root 2001 2000 0 Ağu04 ? 00:00:00 udisks-daemon: not polling any d
mustafa 2009 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfsd-trash --spaw
root 2049 1 0 Ağu04 ? 00:00:00 /usr/sbin/system-tools-backends
mustafa 2071 1 0 Ağu04 ? 00:00:00 /usr/lib/gvfs/gvfsd-metadata
root 2106 1 0 Ağu04 ? 00:00:00 /usr/bin/perl /usr/share/system-
mustafa 2120 1 1 Ağu04 ? 00:00:14 chromium-browser --disable-new-t
mustafa 2124 2120 0 Ağu04 ? 00:00:00 chromium-browser --disable-new-t
mustafa 2125 2120 0 Ağu04 ? 00:00:00 /usr/lib/chromium-browser/chromi
mustafa 2126 2125 0 Ağu04 ? 00:00:00 chromium-browser --type=zygote
mustafa 2130 2126 0 Ağu04 ? 00:00:00 chromium-browser --type=zygote
mustafa 2167 2130 0 Ağu04 ? 00:00:03 /usr/lib/chromium-browser/chro
mustafa 2235 2130 2 Ağu04 ? 00:00:18 /usr/lib/chromium-browser/chro
root 2250 1 0 Ağu04 ? 00:00:00 /sbin/mount.ntfs /dev/sda3 /medi
root 2253 2 0 Ağu04 ? 00:00:00 [jbd2/sda6-8]
root 2254 2 0 Ağu04 ? 00:00:00 [ext4-dio-unwrit]
mustafa 2271 1 0 Ağu04 ? 00:00:00 /usr/lib/libreoffice/program/oos
mustafa 2289 2271 0 Ağu04 ? 00:00:05 /usr/lib/libreoffice/program/sof
mustafa 2305 2130 0 Ağu04 ? 00:00:05 /usr/lib/chromium-browser/chro
root 2312 2 0 00:03 ? 00:00:00 [kworker/0:1]
root 2314 2 0 00:09 ? 00:00:00 [kworker/1:0]
root 2315 2 0 00:09 ? 00:00:00 [kworker/0:0]
mustafa 2323 1 6 00:11 ? 00:00:01 gedit /media/mustafa/b7b4896e-15
mustafa 2329 1 6 00:11 ? 00:00:00 mate-terminal
mustafa 2334 2329 0 00:11 ? 00:00:00 gnome-pty-helper
mustafa 2335 2329 3 00:11 pts/0 00:00:00 bash
mustafa 2383 2335 0 00:11 pts/0 00:00:00 ps -ef
mustafa@mustafa-Lenovo-G550 ~ $
</textarea><br />
<br />
<div style="margin-bottom: 0cm;">
<b>Sample listing of running processes
from top command:</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<textarea style="background-color: #2c3539; color: #8afb17; height: 242px; margin: 2px; width: 659px;">mustafa@mustafa-Lenovo-G550 ~ $ top
top - 00:14:58 up 18 min, 2 users, load average: 0,26, 0,24, 0,21
Tasks: 145 total, 2 running, 143 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1,2 us, 1,0 sy, 0,0 ni, 97,3 id, 0,5 wa, 0,0 hi, 0,0 si, 0,0 st
KiB Mem: 2011432 total, 1398156 used, 613276 free, 96836 buffers
KiB Swap: 487420 total, 0 used, 487420 free, 643724 cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1215 root 20 0 167m 26m 12m S 3,0 1,4 0:31.58 Xorg
10 root 20 0 0 0 0 S 0,3 0,0 0:02.60 ksoftirqd/1
2235 mustafa 20 0 959m 128m 25m S 0,3 6,6 0:30.43 chromium-browse
2289 mustafa 20 0 1113m 118m 66m S 0,3 6,0 0:06.83 soffice.bin
2329 mustafa 20 0 520m 16m 11m S 0,3 0,8 0:02.65 mate-terminal
2398 mustafa 20 0 26156 1628 1152 R 0,3 0,1 0:00.10 top
1 root 20 0 24500 2460 1356 S 0,0 0,1 0:00.65 init
2 root 20 0 0 0 0 S 0,0 0,0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0,0 0,0 0:00.51 ksoftirqd/0
6 root rt 0 0 0 0 S 0,0 0,0 0:00.00 migration/0
7 root rt 0 0 0 0 S 0,0 0,0 0:00.00 watchdog/0
8 root rt 0 0 0 0 S 0,0 0,0 0:00.01 migration/1
11 root rt 0 0 0 0 S 0,0 0,0 0:00.01 watchdog/1
12 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 cpuset
13 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 khelper
14 root 20 0 0 0 0 S 0,0 0,0 0:00.00 kdevtmpfs
15 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 netns
17 root 20 0 0 0 0 S 0,0 0,0 0:00.00 sync_supers
18 root 20 0 0 0 0 S 0,0 0,0 0:00.00 bdi-default
19 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 kintegrityd
20 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 kblockd
22 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 ata_sff
23 root 20 0 0 0 0 S 0,0 0,0 0:00.00 khubd
24 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 md
25 root 20 0 0 0 0 S 0,0 0,0 0:00.31 kworker/0:2
26 root 20 0 0 0 0 S 0,0 0,0 0:02.00 kworker/1:1
27 root 20 0 0 0 0 S 0,0 0,0 0:00.00 khungtaskd
28 root 20 0 0 0 0 S 0,0 0,0 0:00.00 kswapd0
29 root 25 5 0 0 0 S 0,0 0,0 0:00.00 ksmd
30 root 39 19 0 0 0 S 0,0 0,0 0:00.00 khugepaged
31 root 20 0 0 0 0 S 0,0 0,0 0:00.00 fsnotify_mark
32 root 20 0 0 0 0 S 0,0 0,0 0:00.00 ecryptfs-kthrea
33 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 crypto
42 root 0 -20 0 0 0 S 0,0 0,0 0:00.00 kthrotld
</textarea>
<br />
<br />
<br />
<div style="margin-bottom: 0cm;">
<b>Killing
Processes</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
To kill a process,
we can use PID(process id). As you can see from outputs of two
commands above we have process ids for each running process. For
example, to kill PID 217 we type kill 217. This command will kill the
process have PID of 217. To suspend (stop) a running process use kill
-STOP PID, to continue to a suspended process use kill -CONT PID.
</div>
<div style="margin-bottom: 0cm;">
Example: As an
example run an application, find its PID using above commands, and
first kill, then suspend and later allow to continue the process.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Finally, we
finished the tuning process techniques in linux. I hope it will help
you..
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>If you have
any question or need some help about tuning process , leave a comment
below.</b></span></div>
<br />
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-89634193411707412692013-08-04T00:42:00.000+03:002013-08-04T00:42:42.024+03:00Format USB(flash drive) From Terminal <div style="margin-bottom: 0cm;">
It's easy to
format usb drives from terminal. But, you need to first find what's
your usf file system. To find this we can use <b>df</b> command.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>df: </b>report
file system disk space usage </div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Also, to be able
to format the usb, usb shouldn't be mount, if it is we are going to
unmount it.
</div>
<div style="margin-bottom: 0cm;">
Now, just to be
clear I am going to format my own usb step by step, at required steps
I will give the terminal screenshots.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Steps I have down:<br />
<br />
<b><span style="color: red;"> 1.</span></b> type<b> df</b> command into terminal</div>
<div style="margin-bottom: 0cm;">
<br />
terminal output:</div>
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 190px; margin: 2px; width: 667px;">mustafa@mustafa-Lenovo-G550 ~ $ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 40794700 24120308 14602124 63% /
udev 996512 4 996508 1% /dev
tmpfs 402288 1008 401280 1% /run
none 5120 0 5120 0% /run/lock
none 1005716 276 1005440 1% /run/shm
none 102400 8 102392 1% /run/user
/dev/sda3 154622972 133789684 20833288 87% /media/mustafa/6266637866634BBB
/dev/sda6 27667488 17288020 8974028 66% /media/mustafa/b7b4896e-1570-4477-8535-31b2a6c7f8a5
</textarea><br />
<br />
<br />
<span style="color: red;"><b> 2.</b></span> Plug in usb (flash drive)<br />
<span style="color: red;"><b>3. </b></span>type<b> df</b> command into terminal<br />
<br />
termainal output:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 190px; margin: 2px; width: 667px;">mustafa@mustafa-Lenovo-G550 ~ $ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 40794700 24122360 14600072 63% /
udev 996512 4 996508 1% /dev
tmpfs 402288 1008 401280 1% /run
none 5120 0 5120 0% /run/lock
none 1005716 276 1005440 1% /run/shm
none 102400 8 102392 1% /run/user
/dev/sda3 154622972 133789684 20833288 87% /media/mustafa/6266637866634BBB
/dev/sda6 27667488 17288020 8974028 66% /media/mustafa/b7b4896e-1570-4477-8535-31b2a6c7f8a5
/dev/sdb 7801448 2044868 5756580 27% /media/mustafa/A875-7CDC
</textarea>
<br />
<br />
<br />
<div style="margin-bottom: 0cm;">
As you can see we
have a new entry at the last row, which is should be my usb. It's
file system is given as /dev/sdb at terminal output of df command.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b style="color: red;"> 4. </b> to unmount the flash drive type: sudo umount /dev/sdb</div>
<div style="margin-bottom: 0cm;">
<b style="color: red;"> 5. </b>to format the usb as fat type: sudo mkfs.vfat -I /dev/sdb</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
You can see the
terminal executions of step 4 and 5 below: </div>
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 135px; margin: 2px; width: 468px;">root@mustafa-Lenovo-G550:~# sudo -s
root@mustafa-Lenovo-G550:~# umount /dev/sdb
root@mustafa-Lenovo-G550:~# mkfs.vfat -I /dev/sdb
mkfs.vfat 3.0.9 (31 Jan 2010)
root@mustafa-Lenovo-G550:~# that's it we are done!
</textarea>
<br />
<br />
<br />
<div style="margin-bottom: 0cm;">
That's it we are
done, I hope it helps..</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>If you have
any question or need some help about format usb drives, leave a
comment below.</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b><br /></b></span></div>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0İzmir, Türkiye38.41885 27.1287199999999338.41885 27.12871999999993 38.41885 27.12871999999993tag:blogger.com,1999:blog-2004034746111286734.post-25337428483624464152013-08-03T00:03:00.001+03:002013-08-03T00:13:58.562+03:00System Logs in Linux<b>Introduction to syslogd</b>
<br />
<div style="margin-bottom: 0in;">
syslog daemon
responsible from syslog. This structure collects all messages from
running programs to the logs. It categorizes all of messages
according to its types and priority, and presents to us. This is very
useful for error debugging. We can use this messages to find the
actual problem if we have any one at any time. Actually I used that
in <a href="http://eeecoder.blogspot.com/2013/07/wireless-networks-are-not-being-seen-by.html">my previous post.</a> You may wanna see it.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Reading Logs</b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Now, let's look at
how we can read logs. FHS determines the location of logs as
/var/log. We can use tail command to read last ten messages like
that:
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
cd /var/log</div>
<div style="margin-bottom: 0in;">
tail messages #
note: if you don't see anything or get no file error type: tail
syslog</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
output of this
command:</div>
<div style="margin-bottom: 0in;">
<br /></div>
<textarea style="background-color: #2c3539; color: #8afb17; height: 257px; margin: 2px; width: 655px;">mustafa@mustafa-Lenovo-G550:/var/log$ tail syslog
Aug 2 10:42:21 mustafa-Lenovo-G550 pppd[3332]: Sent 950093 bytes, received 7980298 bytes.
Aug 2 10:42:21 mustafa-Lenovo-G550 NetworkManager[882]: nm_system_iface_flush_routes: assertion `ifindex > 0' failed
Aug 2 10:42:21 mustafa-Lenovo-G550 NetworkManager[882]: nm_system_iface_flush_addresses: assertion `ifindex > 0' failed
Aug 2 10:42:21 mustafa-Lenovo-G550 pppd[3332]: Connection terminated.
Aug 2 10:42:21 mustafa-Lenovo-G550 avahi-daemon[873]: Withdrawing workstation service for ppp0.
Aug 2 10:42:21 mustafa-Lenovo-G550 NetworkManager[882]: SCPlugin-Ifupdown: devices removed (path: /sys/devices/virtual/net/ppp0, iface: ppp0)
Aug 2 10:42:21 mustafa-Lenovo-G550 modem-manager[868]: <info> Modem /org/freedesktop/ModemManager/Modems/0: state changed (connected -> disconnecting)
Aug 2 10:42:21 mustafa-Lenovo-G550 dbus[851]: [system] Activating service name='org.freedesktop.nm_dispatcher' (using servicehelper)
Aug 2 10:42:21 mustafa-Lenovo-G550 dbus[851]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Aug 2 10:42:24 mustafa-Lenovo-G550 modem-manager[868]: <info> Modem /org/freedesktop/ModemManager/Modems/0: state changed (disconnecting -> registered)
mustafa@mustafa-Lenovo-G550:/var/log$
</textarea> <br />
<br />
<br />
<div style="margin-bottom: 0in;">
As you can see
from last ten messages, at 10:42:24 I disconnected the modem I cut
the internet, which is a message from network manager and it have
saved into syslog.
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<b>Following Logs from tail</b></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
A system
administrator would use tail -f command to follow log messages like
that:</div>
<div style="margin-bottom: 0in;">
tail -f
/var/log/messages or tail -f /var/log/syslog</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Because by using
-f parameter with tail command, we can read new messages from running
programs at right now. This is very handful for debugging. Also,
almost all system manager executes that command in another terminal
all the time, to see the messages coming through when the programs
are running.</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
Let's see how it
works: I entered the command to read syslog continuously, and I
disabled eth0 in another terminal, the terminal views are given
below:</div>
<div style="margin-bottom: 0in;">
<br /></div>
terminal 1:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 87px; margin: 2px; width: 519px;">mustafa@mustafa-Lenovo-G550 ~ $ sudo -s
[sudo] password for mustafa:
mustafa-Lenovo-G550 ~ # ifconfig eth1 down
</textarea><br />
<br />
terminal 2:<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 59px; margin: 2px; width: 525px;">mustafa-Lenovo-G550 ~ # tail -f /var/log/syslog
Aug 2 14:05:04 mustafa-Lenovo-G550 NetworkManager[696]: <info> (eth1): supplicant interface state: disconnected -> disabled </textarea><br />
<br />
<br />
<div style="margin-bottom: 0in;">
As you can see
from terminal 2, message says eth1 disabled when we type and entered
ifconfig eth1 down into other terminal. It works :).
</div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="color: red;"><b>If you have
any question or need some help about system logs in linux, leave a
comment below.</b></span><br />
<span style="color: red;"><b><br /></b></span></div>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-3798869737913369392013-08-02T19:16:00.000+03:002013-08-02T00:35:32.126+03:00Gimp The GNU Image Manipulation ProgramGimp is an alternative software to Photoshop. Most users of linux use Gimp instead of Photoshop. Last version of Gimp is 2.8. I use it myself in my ubuntu 11.10 Oneiric Ocelot and Linux Mint 1.14 Nadia.<br />
<br />
I recommend it to you if you are using a distiribution of linux. If you are using Windows or other platforms, I think Photoshop is better than Gimp. As we know it is more common than Gimp.<br />
<br />
<span style="color: red;"><b> Features:</b></span><br />
<ul>
<li>Customizable Interface </li>
<li>Photo Enhancement</li>
<li>Digital Retouching</li>
<li>Hardware Support</li>
<li>File Formats (jpeg, gif, png, tiff, psd.)</li>
<li>Supported platforms</li>
<ul>
<li>GNU/Linux (i386, PPC)</li>
<li>Microsoft Windows (XP, Vista)</li>
<li>Mac OS X</li>
<li>Sun OpenSolaris</li>
<li>FreeBSD</li>
</ul>
</ul>
<div>
<span style="color: red;"><b>Last Version:</b></span> Gimp 2.8</div>
<div>
<br /></div>
<div>
To download Gimp you can use the following link which is from its official website:</div>
<div>
<a href="http://www.gimp.org/downloads/">http://www.gimp.org/downloads/</a></div>
<div>
Also you can download some documentation from:</div>
<div>
<a href="http://www.gimp.org/docs/">http://www.gimp.org/docs/</a></div>
<div>
<br /></div>
<div>
<b style="color: red;"> Some Screenshots: </b>You can see in original dimensions by clicking the pics below.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZEnF8gOWOsMeKl-MqeqtMuw48ILBqb2S0zAGp_6DbtItLkeewHlhKuoJztAYEHyHbxiSwYs7Mm6sLxobntzkE2gVf6O6EZ1SFWeDxST1kDJz2vpBlPWwcXrbm5W4VIWy-yC791tqGkcw/s1600/gimp-screenshot1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZEnF8gOWOsMeKl-MqeqtMuw48ILBqb2S0zAGp_6DbtItLkeewHlhKuoJztAYEHyHbxiSwYs7Mm6sLxobntzkE2gVf6O6EZ1SFWeDxST1kDJz2vpBlPWwcXrbm5W4VIWy-yC791tqGkcw/s320/gimp-screenshot1.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gimp Screenshot 1</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8QxiWGP3VF9bWf7danQtA-MX0Qgc55rjtiIuYXH7wMS3UOprV7xugf875d59MU_X3Osen95Ht062D6gqd_SbaTGTPmYo2rgZ3NGvDaeNCLk9FyYTqRy1wk2dcO7fu9anQsf-fBMAoKEg/s1600/gimp3.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8QxiWGP3VF9bWf7danQtA-MX0Qgc55rjtiIuYXH7wMS3UOprV7xugf875d59MU_X3Osen95Ht062D6gqd_SbaTGTPmYo2rgZ3NGvDaeNCLk9FyYTqRy1wk2dcO7fu9anQsf-fBMAoKEg/s320/gimp3.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gimp Screenshot 2</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPl1lL5I7VHA2v9qbzqC8EzXqJb9viY7iTm8687U-y-9CBabqbGqg2mcgThqcfy2fFbrwEct9aS0teY-Pyxl_6ny9l3uCy4UzDXhUa1zEZJivn8ip5hrniHzJl1kDBkZXkMEil6hn4AVc/s1600/gimp-screenshot2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPl1lL5I7VHA2v9qbzqC8EzXqJb9viY7iTm8687U-y-9CBabqbGqg2mcgThqcfy2fFbrwEct9aS0teY-Pyxl_6ny9l3uCy4UzDXhUa1zEZJivn8ip5hrniHzJl1kDBkZXkMEil6hn4AVc/s320/gimp-screenshot2.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gimp Screenshot 3</td></tr>
</tbody></table>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-49599683369850602522013-07-31T11:11:00.001+03:002013-08-03T13:39:40.924+03:00Wireless networks are not being seen by network manager<span style="color: red;"><b>Summary:</b></span> In this article I am going to show you the solution of the problem: wireless networks are not being seen by network manager even if wireless card drivers are installed.<br />
<br />
Yesterday, I reinstalled Linux 1.14 Nadia in my pc. After that I installed my wireless card driver which is Broadcom Corporation BCM4312. I learned its name and version from lspci command. <b><span style="color: red;">lspci</span></b><span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;"> is a command on Unix-like operating systems that prints detailed information about all PCI buses and devices in the system. After that I installed the driver using method 1 which is I explained earlier in <a href="http://eeecoder.blogspot.com/2013/07/linux-mint-114-nadia-wireless-problem.html">that post.</a></span></span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;"><br /></span></span>
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;">Everything was ok, I used the internet connection for hours, but after that I encountered a new problem. </span></span><span style="font-family: 'Apple Garamond'; line-height: 19.200000762939453px;">The wireless was working well but it couldn't see any wireless connections. I thought, I can use error debugging techniques in linux to find the actual problem.</span><br />
<br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;">I am going to explain Error debugging techniques in linux at an article in the next days. </span></span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;"><br /></span></span>
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;">So, I opened a terminal and I typed in:</span></span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;"><br /></span></span>
<textarea style="background-color: #2c3539; color: #8afb17; height: 25px; margin: 2px; width: 273px;">$ tail -f /var/log/syslog</textarea>
<span style="font-family: 'Apple Garamond'; line-height: 19.200000762939453px;"> </span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;">syslog is a .txt file which includes all errors, messages and notifications coming from apps, softwares etc. And the most beautiful property is we can view at this moment what is going on about an application or software. Once you typed in above command it will show the new errors or messages too. </span></span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;">When I typed in that command , and view messages, I clicked the icon at the right bottom of desktop and then >>Connect to Hidden Wireless Network , I choosed an past connection which I used before. And click connect. My purpose was to interact with network manager and see if it has a problem if it is see in the syslog. When I did this I saw an input to syslog which is shown below:</span></span><br />
<span style="font-family: Apple Garamond;"><span style="line-height: 19.200000762939453px;"><br /></span></span>
<textarea style="background-color: #2c3539; color: #8afb17; height: 150px; margin: 2px; width: 675px;">Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Auto-activating connection 'teknomarketim.com'.
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) starting connection 'teknomarketim.com'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> (eth1): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 1 of 5 (Device Prepare) scheduled...
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 1 of 5 (Device Prepare) started...
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 2 of 5 (Device Configure) scheduled...
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 1 of 5 (Device Prepare) complete.
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 2 of 5 (Device Configure) starting...
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> (eth1): device state change: prepare -> config (reason 'none') [40 50 0]
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1/wireless): connection 'teknomarketim.com' has security, and secrets exist. No new secrets needed.
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: added 'ssid' value 'teknomarketim.com'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: added 'scan_ssid' value '1'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: added 'key_mgmt' value 'NONE'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: added 'wep_key0' value '<omitted>'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: added 'wep_tx_keyidx' value '0'
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Activation (eth1) Stage 2 of 5 (Device Configure) complete.
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> Config: set interface ap_scan to 1
Jul 31 10:28:58 mustafa-Lenovo-G550 NetworkManager[692]: <info> (eth1): supplicant interface state: inactive -> scanning
</textarea>
<br />
<br />
As you see in the last rows, it is saying eth1 is not active.(inactive) <b><span style="color: red;">We found the actual problem!</span></b>. Now we are going to solve it.. I typed the following commands into terminal to stop and restart again eth1 interface.<br />
<br />
<textarea style="background-color: #2c3539; color: #8afb17; height: 70px; margin-left: 2px; margin-right: 2px; width: 616px;">$sudo ifconfig eth1 down
$sudo ifconfig eth1 up
$sudo service network-manager restart
</textarea>
<br />
<br />
This solved my problem. I hope it solves your problem too..<br />
<br />
<span style="color: red;"><b>If you have any question or need some help, leave a comment below.</b></span>Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-2723669946097263232013-07-28T01:19:00.002+03:002013-07-28T13:47:20.780+03:00Dice Simulation with C or C++I wanted to model the dice simulation using C or C++. You can see the codes in the following.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTANeBmvEylh0pGwBMe_jzHq8LEARcYDNCvE2O-m_xVHFZYAzqzik_s3vRv1e4ZeQUkL_OJPsOUk_55scxE7IDMbPwGpEP7Q_EfcbYn6sJHGoOJPsCE4IJl19um4S1ZhgDBDMIyQe9z-E/s1600/Screenshot+at+2013-07-27+08%253A10%253A49.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTANeBmvEylh0pGwBMe_jzHq8LEARcYDNCvE2O-m_xVHFZYAzqzik_s3vRv1e4ZeQUkL_OJPsOUk_55scxE7IDMbPwGpEP7Q_EfcbYn6sJHGoOJPsCE4IJl19um4S1ZhgDBDMIyQe9z-E/s640/Screenshot+at+2013-07-27+08%253A10%253A49.png" width="640" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-66969304435126788732013-07-28T01:14:00.000+03:002013-07-28T01:17:00.790+03:00C veya C++ ile Zar Atma SimulasyonuBu programımda zar atmayı C ile
modellemek istedim. Program kodlarını aşağıda görebilirsiniz.<br />
<div style="margin-bottom: 0in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKkOwRNnS87LOZXfrbYaArBVsaasE6yk6uBIcgH-in37jv9JL5NeTWUCCRgdCqSAm32nvWGhw_uYCSOiW7T7vePx6BR3B0mYHS3FrsLSTO1Lv2DFcme157GeV3f6wdagfNbjxjngt_DBw/s1600/Screenshot+at+2013-07-27+08:10:49.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKkOwRNnS87LOZXfrbYaArBVsaasE6yk6uBIcgH-in37jv9JL5NeTWUCCRgdCqSAm32nvWGhw_uYCSOiW7T7vePx6BR3B0mYHS3FrsLSTO1Lv2DFcme157GeV3f6wdagfNbjxjngt_DBw/s640/Screenshot+at+2013-07-27+08:10:49.png" width="640" /></a></div>
<div style="margin-bottom: 0in;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0tag:blogger.com,1999:blog-2004034746111286734.post-64231328617763675952013-07-25T20:35:00.000+03:002013-08-23T11:30:44.713+03:00CPU Sıcaklık Alarmı Sistemi<script type="text/javascript"><!--
google_ad_client = "ca-pub-9384858954425908";
/* eeecoder_footer_AdSense1_468x60_as */
google_ad_slot = "9662600277";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br /> <br />
Merhabalar, bu yazımda linux kernel ve linux shell in verdiği harika avantajlardan faydalanarak yaptığım CPU Sıcaklık Alarmı Sistemini anlatmak istedim.<br />
<br />
Linux un bize sağladığı en büyük avantajlardan biri kolaylıkla hardware bileşenlerine ulaşabilmemizdir. Hardware ile iletişim şu şekilde gerçekleşir :<br />
<br />
<b><span style="color: red;">1. </span></b>Kullanıcı isteklerini kodlar halinde yazar.<br />
<span style="color: red;"><b>2.</b></span> Shell bu kodları linux kernel in anlayabileceği dile çevirir.<br />
<b><span style="color: red;">3.</span></b> Kernel ise hardware ile shell arasındaki iletişimi sağlayan bir nevi arayüz diyebileceğimiz bir sistemdir. Kernel bu istekleri hardware bileşenlerine iletir.<br />
<br />
Bu basit adımları ve daha fazlasını şema olarak aşağıdaki resimden anlayabilirsiniz..<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihyphenhyphenrJI7MwVnMM8v-NH_LdU-DSHaHZCRd5xnADMtYYETZ7WRm5gDHFW4ZZllfHuH2bmPn9Kjkq8iPymSGjcEB52lAEUWGHWq9DDSHjfG5qkSLcrhXaGlayQzfGOiKQyOs-XavtGyVXn14g/s1600/download.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihyphenhyphenrJI7MwVnMM8v-NH_LdU-DSHaHZCRd5xnADMtYYETZ7WRm5gDHFW4ZZllfHuH2bmPn9Kjkq8iPymSGjcEB52lAEUWGHWq9DDSHjfG5qkSLcrhXaGlayQzfGOiKQyOs-XavtGyVXn14g/s1600/download.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Resimden görüldüğü gibi linuxtaki uygulamalarda çalışırken önce shell ve user ile iletişime geçerler. Daha sonra shell uygulamanın isteklerini kernel e anladığı dilde iletir. Kernel de bu istekleri hardware bileşenlerine iletir. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Düşündüm ki madem böyle o zaman:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: red;"><b>1. </b></span>CPU nun sıcaklığı için önce cpu nun sıcaklığını ölçen bir hardware bileşenimiz olan sensörlere ulaşmam lazım. Linux ta bu işi yapan basit komut : 'acpi -t' komutudur.</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: red;"><b>2.</b></span> Sensors komutu şu şekilde bir çıktı verecektir: </div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both;">
Thermal 0: ok, 46.0 degrees C</div>
<div>
Buradaki 46.0 değeri cpu nun santigrat cinsinden sıcaklığıdır. </div>
<div>
<b><span style="color: red;">3. </span></b>Bu cevapta benim ihtiyacım olan sadece 46.0 değeridir. Bu değeri bu satırdan çekmek için ise şu komutu kullandım: awk '{print $4}'.. Herhangi bir linux dağıtımı kullanıyorsunuz, illa ki awk ı duymuşsunuzdur. Awk dilleri ya da yazıları scan ve process etme pattern idir. Benim bu adımda yaptığım gibi.( 46.0 değerini şu cevaptan çektik>>Thermal 0: ok, 46.0 degrees C)</div>
<div>
<span style="color: red;"><b>4.</b></span> Daha sonraki adımda kendi belirleyeceğim bir değerle cpu sıcaklığını karşılaştırıp, bir alarm zili çaldırmak istedim. (Eğer cpu sıcaklığı benim belirlediğim değerden yüksek ise.). Bu basit karar verme bloku için tabiki 'if else fi ' blokları yardımımıza koşacaktır. </div>
<div>
<b><span style="color: red;">5.</span></b> Dördüncü adımda bir alarm zili çaldırmak istediğimi söylemiştim. Bunu sağlamak için sox paketini kullandım. Sox paketindeki play komutu .wav vb. dosyaları çalıştırmamızı sağlar.<br />
<br />
Anlattığım bu adımları gerçekleştirdiğim scripti aşağıda görebilirsiniz. Script doğru bir şekilde çalışıyor..<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZCj3JUanlChCKs-9spx6LOoFAoukz7EegQDcjBmNHitLCCObkzbKXA1WzaKVx-bF9uPYA1rEL0j9soKgC4Iin1DcMGnyLMkFcC6UKMddD3RS0ZntWZ4XfB5x5FwcPqswFGAp6sajB340/s1600/cputemperaturealarmsystem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZCj3JUanlChCKs-9spx6LOoFAoukz7EegQDcjBmNHitLCCObkzbKXA1WzaKVx-bF9uPYA1rEL0j9soKgC4Iin1DcMGnyLMkFcC6UKMddD3RS0ZntWZ4XfB5x5FwcPqswFGAp6sajB340/s1600/cputemperaturealarmsystem.png" /></a></div>
<br />
<b><span style="color: red;"> Herhangi bir sorunuz ya da yardıma ihtiyacınız varsa, aşağıya yorum bırakabilirsiniz.</span></b><br />
<span style="color: red;"><b> Yazıyı beğendiyseniz, beğen butonlarını kullanarak bloguma destek verebilirsiniz.</b></span></div>
<br />
<br />
<script type="text/javascript"><!--
google_ad_client = "ca-pub-9384858954425908";
/* eeecoder_footer_AdSense1_728x90_as */
google_ad_slot = "5232400677";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
<br />Anonymoushttp://www.blogger.com/profile/16560304904949825287noreply@blogger.com0