Skip to content

Instantly share code, notes, and snippets.

View junaidk's full-sized avatar

Junaid Khalid junaidk

  • Mirantis
  • Berlin
View GitHub Profile
@junaidk
junaidk / ReadMe
Last active October 2, 2023 06:31
Code to decipher Vigenere Cipher Using frequency analysis
First find the strings of characters that are repeated in the ciphertext.The distances between consecutive occurrences of the strings are likely to be multiples of the length of the keyword. Then factors each of these numbers. If any number is repeated in the majority of these factorings, it is likely to be the length of the keyword.
After finding keyword length ...
We find k0 (first letter of keyword) first. Each of the characters y0, yL, y2L,
y3L, y4L, ..., y(q–1)L (q ≈ n / L)have been encrypted by adding k0 . Essentially, if we restrict to these characters, we have a simple shift cipher with shift k0.) We count the frequency of each letter (A, B, ..., Z) in these q characters of the ciphertext, and divide these frequencies by q to obtain probabilities.
Let W = (w0, w1, ..., w25), where w0, w1, ..., w25 are the probabilities of A, B, ..., Z in
positions 0, L, 2L, ..., (q−1)L of the ciphertext.
w0, w1, ..., w25 are the probabilities of A− k0, B− k0, ..., Z− k0 in
the plaintext (same positions).
@junaidk
junaidk / gist:5693223
Last active December 17, 2015 23:58
Cocos 2dx setup
##import into eclipse
(http://stackoverflow.com/questions/12654078/cocos2d-x-android-cant-resolved-coscos2dx-library)
In cocos2d-x 2.0.3 ...Cocos2d-x Lib java files has been considered as a different project only So import that project in the eclipse
Lets make it Simple
First Import the project in eclipse from this path - cocos2d-2.0-x-2.0.3/cocos2dx/platform/android/java
You will see libcocos2dx project in eclipse ...Keep this project open always otherwise your projects will give error on the syntax of library
Run create-android-project
@junaidk
junaidk / arrayShuffle.cpp
Last active December 18, 2015 02:48
Shuffle an array
// C Program to shuffle a given array
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// A utility function to swap to integers
void swap (int *a, int *b)
{
int temp = *a;
@junaidk
junaidk / gist:6131963
Created August 1, 2013 14:34
Cocos2dx action sequence -- call a function after an action completion
int *value = new int(3);
CCLog("*value = %d", *value); //=> I get 3 here => ok
_coinsLabel->runAction((CCSequence*)CCSequence::actions(
CCDelayTime::actionWithDuration(.05f),
CCCallFuncND::actionWithTarget(this, callfuncND_selector(GameLayer::addCoins),(void*) value),
NULL));
//function to called
void GameLayer::addCoins((CCNode* sender, void* data)
{
@junaidk
junaidk / gist:7674306
Created November 27, 2013 11:34
Matlab dragNdrop
%% define each of these functions in separate function files
%% with file name equal to function name
%1
function dropObject(hObject,eventdata)
global dragging ;
global orPos ;
global axisSize;
if ~isempty(dragging)
<!doctype>
<html>
<head>
<title>Detecting Key-Combo Events With jQuery</title>
<script type="text/javascript" src="./jquery-1.7.1.js"></script>
<script type="text/javascript">
// Run when the DOM has loaded.
$(function(){
@junaidk
junaidk / Cocos-touch.cpp
Last active January 4, 2016 08:39
Cocos-touch prototype And Bootstrap Scene Files
void Scene1::ccTouchesBegan(CCSet* pTouches, CCEvent* event){
CCSetIterator i;
CCTouch* touch;
CCPoint tap;
GameSprite* tempGmSprite;
CCSprite* tempBand;
for( i = pTouches->begin(); i != pTouches->end(); i++) {
touch = (CCTouch*) (*i);

creat a text file with name .nanorc and add following lines in it

include "/usr/share/nano/java.nanorc"
include "/usr/share/nano/c.nanorc"

copy the java.nanorc &amp; c.nanorc files using following commands
cp /usr/share/nano/java.nanorc .
cp /usr/share/nano/c.nanorc .
@junaidk
junaidk / gist:8827646
Last active June 1, 2017 11:06
Ubuntu Proxy

Proxy Setting for Apt is needed for us who work behind proxy. It is needed for ubuntu update, package installation, and ubuntu upgrade. This proxy setting used by apt can be configured with apt.conf and if it’s not configured ubuntu will use or read proxy configuration environtmen. read this post setting proxy bactrack or ubuntu to set proxy environtmen. On ubuntu 10.04 we can find apt.conf in /etc/apt, but on ubuntu 11.04 i can’t find this file. Reading from some articles i found out that ubuntu 11.04 will still read apt.conf configuration if this file is exist. so i just create file apt.conf in /etc/apt/

  1. Create apt.conf nano /etc/apt/apt.conf

  2. Insert folowing line in this file

Acquire::http::proxy "http://proxyserver:port/";
@junaidk
junaidk / wireless.md
Created February 7, 2014 20:28
Windows 8.1 & 8 wireless configuration

###For Windows 8.1 do the following:

  1. Go to command line ( Administrator)
  2. run this command : netsh
  3. netsh> wlan
  4. netsh wlan> show profiles
  5. delete profile name=wireless (if it exists)
  6. Setup wireless manually using the usual settings.
  7. netsh wlan> set profileparameter name=wireless authentication=wpa encryption=aes