Skip to content

Instantly share code, notes, and snippets.

View anil826's full-sized avatar
🏠
Working from home

Anil anil826

🏠
Working from home
  • New Delhi , India
View GitHub Profile
@anil826
anil826 / remove_brew-mongo_osx.sh
Created June 8, 2017 13:23 — forked from katychuang/remove_brew-mongo_osx.sh
remove mongodb that was installed via brew
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
//Below method is for updating the attributes of User
$('#user_update').submit(function (event) {
//Prevent default action
event.preventDefault();
//change button state
var $btn = $('#user_update_button').button('loading');
//Get org id
var user_id = $('input[name="user_id"]').val();
//get form input fields
var data = {
@anil826
anil826 / test.js
Created July 21, 2017 06:37
JsonToBytes
const bytes = function(s) {
return ~-encodeURI(s).split(/%..|./).length
}
const jsonSize = function(s){
return bytes(JSON.stringify(s))
}
console.log(jsonSize({foo: 'bar'})) //=> 13
@anil826
anil826 / zip-phone_number-validaton.md
Created August 29, 2017 09:56
formyoula-zip-phone_number-validaton

You can add custome validation on Number & Text elements.

ex: Phone Number & ZIP Code

Phone Number Validation:

  • input | data-parsley-excluded | false

  • input | data-parsley-type | digits

  • input | data-parsley-length | [10, 10]

@anil826
anil826 / single_attribute_update_mongo.txt
Created September 7, 2017 06:31
Update Single attributes in Mongo db
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
@anil826
anil826 / single_attribute_update_mongo.txt
Created September 7, 2017 06:31
Update Single attributes in Mongo db
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
@anil826
anil826 / example.html
Last active January 15, 2023 17:51
Jquery-lan-translator
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<div>
<div>
<div>
$(function() {
//store select options values to map the options.
var data = window.formyoula.form_fields["719d-648d-5b11"].get("attributes").select_option_values.split("\n");
//Formyoula form select element component id to get child select list values to map with options.
$("#component-719d-648d-5b11 select > option").each( function( index, element ) {
//If check for skiping the "--None--" at index 0.
if ( index > 0 ) element.value = data[index-1];
});
});
@anil826
anil826 / MultiSelect_example.js
Last active December 13, 2017 12:15
MultiSelect_example
//To run this below JS we need Formyoula multi-select filed and a JavaScript field.
//Fill the Multi-Select Optional values based on multi-select options.
$('select').change(function() {
//Init a array for final data.
var final_element = [];
//Get all the selected element.
var selected_element = $( this ).val();
//Each loop for get/set the values of selected elements.
_.each(selected_element,function(data){
@anil826
anil826 / SelectLIst_email_connection.js
Created December 14, 2017 06:16
Email connection using Select list and hidden filed
//Below example is used when admin don't want to expose the emails on Entry List view.
//To run below JS we need one formyoula select list element and one hidden filed element.
//Use a Formyoula JavaScript element to run the below JS example.
//Listen to Select List changes
$('select').change(function() {
//Get the options value form formyoula select list element.
var options = window.formyoula.form_fields["abcd-abcd-abcd"].get("select_options").split("\n");
//Set the emails as a Select list optional value. ex: For Options on Select list: Customer Support, Sales Support.
var emails = ["customer@gmail.com","sales@gmail.com"];
//Get the index of changed option.