Skip to content

Instantly share code, notes, and snippets.

View rajankur's full-sized avatar

Raj Ankur rajankur

View GitHub Profile
@rajankur
rajankur / sendSMS.php
Last active August 29, 2015 14:14
PHP: sendSMS via cURL
<?php
/**
* a function for sending sms using curl.
* @param integer $to -must be a valid 10 digit mobile number
* @param string $msg -must be valid message.
* @return string
*/
function sendSms($to,$msg)
{
$username = ""; // The username of SENDER.
@rajankur
rajankur / ftpUpload.php
Last active August 29, 2015 14:14
PHP: upload files via FTP
<?php
/**
* FTP upload lets you upload files to the server via FTP
* @param string $host -host name of the server goes here
* @param string $ftp_user -FTP username
* @param string $ftp_pwd -FTP password
* @param string $filename -filename to save with
* @param string $content -content of the file
* @return boolean
*/
@rajankur
rajankur / customDateTime.php
Last active August 29, 2015 14:14
PHP: custom date time format
<?php
/**
* The function convert an input string to a date with desired format.
* @param string $date
* @param string $format
* @return datetime
*/
function customDate($date,$format)
{
if($date=="" || $date=="0000-00-00 00:00:00")
@rajankur
rajankur / fileUpload.php
Created February 1, 2015 05:45
PHP: file upload
<?php
if(isset($_FILES["file"]))
{
$ext_allowed = array("jpg","png"); // add allowed extensions here
$dir = "uploads"; // Add Directory for uploads here
$name = $_FILES['file']['name'];
$tmp = $_FILES['file']['tmp_name'];
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$newname = substr(md5(rand(1231,483798489)),0,6)."_".strtotime(date('Y-m-d H:i:s'));
@rajankur
rajankur / foreach_alt.android.java
Created February 16, 2015 08:33
Android: for each alternative
HashMap<String, HashMap> selects = new HashMap<String, HashMap>();
for(Entry<String, HashMap> entry : selects.entrySet()) {
String key = entry.getKey();
HashMap value = entry.getValue();
}
@rajankur
rajankur / fetch_all_links.php
Last active August 29, 2015 14:18
PHP: Fetch all links from a webpage
@rajankur
rajankur / problems.md
Last active July 5, 2018 06:37
The problems focuses on testing your programmatic, algorithmic and code writing skills. We would love to get the solutions the "Object Oriented" way. Do not copy :)

Problem 1: write a function to get the value from an array in such a way that the keys are sparated by a dot.

function array_take($array, $keymap) {
    # your code goes here...
}
$person = [
    'name' => [
        'firstname' => 'Raj',
        'lastname' => 'Ankur'
    ],
@rajankur
rajankur / amazon_composer.md
Last active July 3, 2018 16:36 — forked from asugai/Install composer on Amazon AMI running on EC2
Install composer on Amazon AMI running on EC2

Install composer on Amazon AMI running on EC2

$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer

then you can run

@rajankur
rajankur / amazon-ec2-ftp.md
Created August 7, 2016 18:40 — forked from gunjanpatel/amazon-ec2-ftp.md
amazon ec2 LAMP and FTP installation and setup
@rajankur
rajankur / input_file.html
Created September 26, 2016 17:18
Valid Accept types for HTML input tag
<!-- Specifying multiple formats -->
<input type="file" accept=".csv, .txt" />
<!-- For CSV -->
<input type="file" accept=".csv" />
<!-- For Excel 97-2003 -->
<input type="file" accept="application/vnd.ms-excel" />
<!-- For Excel 2007+ -->