Rails RJS redirect
page.redirect_to :action => ‘thanks’, :p1 => @g_resp.params["_code"], :p2 => @r_id
Workaround:
_use_me = frozen_string.dup
page.redirect_to :action => ‘thanks’, :p1 => @g_resp.params["_code"], :p2 => @r_id
Fix:
form style=”margin-top: 0px;margin-bottom: 0px;”
Mysql Getting Random Row: “order by rand()”
Problem:
Fix:
Value State Description
0 Undefined Windows Media Player is in an undefined state.
1 Stopped Playback of the current media item is stopped.
2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.
3 Playing The current media item is playing.
4 ScanForward The current media item is fast forwarding.
5 ScanReverse The current media item is fast rewinding.
6 Buffering The current media item is getting additional data from the server.
7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.
8 MediaEnded Media item has completed playback.
9 Transitioning Preparing new media item.
10 Ready Ready to begin playing.
11 Reconnecting Reconnecting to stream.
Remarks
Windows Media Player states are not guaranteed to occur in any particular order. Furthermore, not every state necessarily occurs during a sequence of events. You should not write code that relies upon state order.
Example Code
The following JScript code shows the use of the player.playState property. An HTML text element, named “myText”, displays the current status. The Player object was created with ID = “Player”.
// Test whether Windows Media Player is in the playing state.
if (3 == Player.playState)
myText.value = “Windows Media Player is playing!”;
else
myText.value = “Windows Media Player is NOT playing!”;
This is how you can run multiple instances of Google talk
c:\> googletalk.exe /nomutex
pretty straight huh !
schtasks /create /tn “My Scheduled Jobs” /tr “php-win.exe D:\Program Files\xampp\htdocs\somefile.php” /sc minute
make sure that php-win.exe is in path while giving this command
Assumption:
- eth0 is the external interface (Connected to internet)
- eth1 is the internal interface (local network) (Fixed IP)
Edit /etc/sysctl.conf to enable ip forwarding permanently.
net.ipv4.ip_forward = 1
Edit /etc/sysconfig/iptables-config and make following changes:
IPTABLES_MODULES=”ip_conntrack_netbios_ns ip_conntrack ip_conntrack_ftp ip_conntrack_irc iptable_nat ip_nat_ftp ip_nat_irc”
IPTABLES_SAVE_ON_STOP=”yes”
IPTABLES_SAVE_ON_RESTART=”yes”
# To clear out any existing rules and set default policy,
# run following commands on command prompt
iptables -P INPUT ACCEPT
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F
# FWD: Allow all connections OUT and only existing and related ones IN
iptables -A FORWARD -i eth0 -o eth1 -m state –state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
# Enabling MASQUERADE functionality on eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Pure ALOHA protocol
Pure ALOHA protocol is a random access protocol used for data transfer.
User accesses a channel as soon as a message is ready to be transmitted. After a transmission the user waits for an acknowledgement on either the same channel or separate feedback channel. In case of collision (i.e. when a NACK is received), the terminal waits for a random period of time and retransmits the message. As the number of users increase, a greater delay occurs because the probability of collision increases.
Slotted ALOHA protocol
In Slotted ALOHA protocol, time is divided into equal time slots of length greater than the packet duration (time taken to transmit a fixed length packet).
The subscribers (users), each have synchronized clocks and transmit a message only at the beginning of a new time slot, thus resulting in a discrete distribution of packets (each subscriber is assigned a time slot in which he can transmit.). (Note here: two users may get same time slot at peak times)
This prevents partial collisions (i.e. packets collide with portion of another). This implies that either a packet will collide completely or not at all.
As the number of users increase a greater delay will occur due to duplicate time slot assignments and hence greater number of complete collisions. Repeated transmission of lost packets would make things even slower.
But, the vulnerable period for slotted aloha is only one packet duration, since partial collisions are prevented through synchronization.
Overall, slotted ALOHA provides a maximum channel utilization of .368 Erlangs, double that of pure ALOHA.
Limitation of Aloha in general
ALOHA protocols do not listen to the channel before transmission, and therefore do not exploit information about other users. By listening to the channel before starting transmission, greater efficiencies may be achieved. This is where CSMA protocols come into the picture which I will cover in a separate post.