Skip to content

Instantly share code, notes, and snippets.

View manjufy's full-sized avatar
💭
Building Stuff

Manjunath Reddy manjufy

💭
Building Stuff
View GitHub Profile
@manjufy
manjufy / combos.php
Created March 3, 2016 09:16 — forked from fabiocicerchia/combos.php
PHP - Generate all the possible combinations among a set of nested arrays.
/**
* Generate all the possible combinations among a set of nested arrays.
*
* @param array $data The entrypoint array container.
* @param array $all The final container (used internally).
* @param array $group The sub container (used internally).
* @param mixed $val The value to append (used internally).
* @param int $i The key index (used internally).
*/
function generate_combinations(array $data, array &$all = array(), array $group = array(), $value = null, $i = 0)
@manjufy
manjufy / jquery-init
Created April 14, 2016 09:47
Ways to Initialise Jquery
// Below one, runs the function when the DOM tree is built
$(document).ready(function({
// Codes goes here
});
$(function() {
// Codes goes here
});
// Runs the funciton right away
@manjufy
manjufy / gist:4cef95b3489c375a4315828a1574cef8
Created December 11, 2016 16:11 — forked from isimmons/gist:8202227
Truncate tables with foreign key constraints in a Laravel seed file.

For the scenario, imagine posts has a foreign key user_id referencing users.id

public function up()
{
	Schema::create('posts', function(Blueprint $table) {
		$table->increments('id');
		$table->string('title');
		$table->text('body');
@manjufy
manjufy / csv_to_array.php
Created December 13, 2016 16:43 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@manjufy
manjufy / webdriverio-chromedrive.md
Last active December 14, 2016 03:56
Using chromedriver with webdriverio

Assume that you are running stand alone Selenium server and you would like to run tests with Chrome browser intead of Firefox or anyother driver Here are the steps to do so

  • Download chromedriver from https://sites.google.com/a/chromium.org/chromedriver/downloads
  • Move to a place where it can be executable and remember the path of the file Ex: /User/abc/chromedriver
  • Start your chrome browser with Selenium server. Ex: java -jar -Dwebdriver.chrome.driver=/Users/abc/chromedriver selenium-server-staalone-3.0.1.jar
@manjufy
manjufy / pagination.md
Last active December 25, 2016 05:44
Laravel snippets (5.3)

Pagination

Laravel pagination is integrated with query builder and Eloquent ORM

Paginating Query Builder Results

Example: In Controller / Model

 $articles = DB::table('article')->paginate(10);
   return view('article.index', ['articles' => $article]);
@manjufy
manjufy / netsuite-salesforce-ws.js
Last active January 6, 2017 04:26
Calling Salesforce Webservice from NetSuite UserEventScript 2.0 (POST / PUT)
function afterSubmit(scriptContext) {
// prepare headers
var headers = {
'Authorization': 'Bearer <your access token>',
'Content-Type': 'application/json',
'accept': '*/*'
};
// prepare body, since I'm Updating a record in Salesforce, I'm using Http Method PUT
var body = {
"field1": "value1",
@manjufy
manjufy / API.md
Created January 10, 2017 06:53 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@manjufy
manjufy / github_post_recieve.php
Created January 13, 2017 10:56 — forked from cowboy/github_post_recieve.php
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@manjufy
manjufy / NetSuiteTBAWS.cls
Last active March 20, 2024 04:20
Salesforce Apex Code for Using Token Based Authentication to call NetSuite RESTlets
@RestResource(urlMapping='/Netsuite/TBA/*')
global with sharing class NetSuiteTBATestWS {
@HttpGet
global static String doGet() {
OAuth10a oAuth = new OAuth10a();
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');