Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output   should be capitalized only if the original word was capitalized.
Examples:
 
#python #codewars
  Examples:
to_camel_case("the-stealth-warrior") # returns "theStealthWarrior"
 to_camel_case("The_Stealth_Warrior") # returns "TheStealthWarrior"#python #codewars
  Tech C**P
 Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output   should be capitalized only if the original word was capitalized.   Examples:   to_camel_case("the-stealth-warrior") # returns…
   Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS)
 
#python #codewars #datetime
  HH = hours, padded to 2 digits, range: 00 - 99
MM = minutes, padded to 2 digits, range: 00 - 59
SS = seconds, padded to 2 digits, range: 00 - 59
#python #codewars #datetime
  Tech C**P
 Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS)   HH = hours, padded to 2 digits, range: 00 - 99  MM = minutes, padded to 2 digits, range: 00 - 59  SS = seconds, padded to…
   If you forget to pull your projects from git in a regular interval and many users working on the same projects, then there is a        solution for you!
Create a bash script file as follow and make it executable by
 
 
 
Now as a final step, put it in your crontab:
 
#linux #git #pull #cronjob #crontab #cron #bash
  Create a bash script file as follow and make it executable by
chmod +x puller.sh:puller.sh file content:#!/bin/bash
echo 'Iterating over folders...'
for dir in *
do
test -d "$dir" && {
cd ${dir}
echo "git pull $dir"
git pull
cd ".."
} || {
echo "------> $dir is not a directory <-------"
}
done
NOTE: this file should reside in your folder's project root. In my case it is in /Your/Projects/Folder.Now as a final step, put it in your crontab:
10 * * * * bash -c "cd /Your/Projects/Folder; bash puller.sh >> /var/log/git_pull_output.log"
#linux #git #pull #cronjob #crontab #cron #bash
Count the number of DuplicatesWrite a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
Example:
"abcde" -> 0 # no characters repeats more than once
"aabbcde" -> 2 # 'a' and 'b'
"aabBcde" -> 2 # 'a' occurs twice and 'b' twice (`b` and `B`)
"indivisibility" -> 1 # 'i' occurs six times
"Indivisibilities" -> 2 # 'i' occurs seven times and 's' occurs twice
"aA11" -> 2 # 'a' and '1'
"ABBA" -> 2 # 'A' and 'B' each occur twice
What is your solution?
#python #codewars
  Tech C**P
Count the number of Duplicates  Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both…
   We have talked before about how to get current month using the below line of code:
 
It prints out 01, 02, etc.
As per the
 
So you can remove leading zero by hyphen as below:
 
It prints out 1, 2, etc.
#linux #bash #date
  echo $(date +%m)
It prints out 01, 02, etc.
As per the
GNU date manpage:By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
So you can remove leading zero by hyphen as below:
echo $(date +%-m)
It prints out 1, 2, etc.
#linux #bash #date
As an alternative to the 
#python #pprint #json #dumps
  pprint module:# The standard string repr for dicts is hard to read:
>>> my_mapping = {'a': 23, 'b': 42, 'c': 0xc0ffee}
>>> my_mapping
{'b': 42, 'c': 12648430. 'a': 23} # 😞
# The "json" module can do a much better job:
>>> import json
>>> print(json.dumps(my_mapping, indent=4, sort_keys=True))
{
"a": 23,
"b": 42,
"c": 12648430
}
# Note this only works with dicts containing
# primitive types (check out the "pprint" module):
>>> json.dumps({all: 'yup'})
TypeError: keys must be a string
#python #pprint #json #dumps
 A 
For example, take 153 (3 digits):
 
and 1634 (4 digits):
 
The Challenge:
Your code must return true or false depending upon whether the given number is a
 
#python #question #codewars
  Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits in a given    base. Here we will restrict ourselves to decimal (base 10).For example, take 153 (3 digits):
1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
and 1634 (4 digits):
1^4 + 6^4 + 3^4 + 4^4 = 1 + 1296 + 81 + 256 = 1634
The Challenge:
Your code must return true or false depending upon whether the given number is a
Narcissistic number in base 10.NOTE: Error checking for text strings or other invalid inputs is not required, only valid integers will be passed into the function.#python #question #codewars
  Tech C**P
 A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits in a given    base. Here we will restrict ourselves to decimal (base 10).   For example, take 153 (3 digits):  1^3 + 5^3 + 3^3 = 1 + 125…
  
  Tech C**P
from math import pow  def narcissistic(value):     digits = map(int, list(str(value)))     power = len(digits)     final_res = 0     for digit in digits:         final_res += pow(digit, power)     return int(value) == int(final_res) #python #solution
   The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers:
 
Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole array. If the list is made up of only negative numbers, return 0 instead.
Empty list is considered to have zero greatest sum. Note that the empty list or array is also a valid sublist/subarray.
#python #codewars
  maxSequence([-2, 1, -3, 4, -1, 2, 1, -5, 4])
# should be 6: [4, -1, 2, 1]
Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole array. If the list is made up of only negative numbers, return 0 instead.
Empty list is considered to have zero greatest sum. Note that the empty list or array is also a valid sublist/subarray.
#python #codewars
Babel:Babel is an integrated collection of utilities that assist in internationalizing and localizing Python applications, with an emphasis on web-based applications.
pip install Babel
More information:
- https://babel.pocoo.org/en/latest/index.html
#python #pocoo #pip #babel #internationalization #localization
 How do you sort the below object based on the value in 
 
Well first you need to make an array of arrays:
 
 
#javascript #sort #alphabetically
  Javascript?{
     "en": "English (English)",
     "fa": "French",
     "ar": "العربیه",
     "zh": "中文 (Chinese)"
 }Well first you need to make an array of arrays:
var sortable_langs = [];
$.each(languages, function(index, language) {
sortable_langs.push([index, language]);
});
sortable_langs.sort(function(a, b) {
if(a[1] < b[1]) { return -1; }
if(a[1] > b[1]) { return 1; }
return 0;
});
NOTE: a[1] and b[1] refers to the language value like: English (English). They are compared with each other. If a[1] is bigger   than b[1] then it will be moved to the first to the top.#javascript #sort #alphabetically
 How to get only numbers in textbox using 
 
#javascript #jquery #input #number
  jQuery?// Restricts input for each element in the set of matched elements to the given inputFilter.
(function($) {
$.fn.inputFilter = function(inputFilter) {
return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
}
});
};
}(jQuery));
// restrict input to receive just numbers
$("#my_input_num").inputFilter(function(value) {
return /^\d*$/.test(value);
});
#javascript #jquery #input #number
 In 
 
The response differs based on the given scope on the first login step. Mine was set to the below:
 
#google #login_with_google #oauth #scope #userinfo #oauth2
  Google OAUTH 2.0 in case you get a token from Google Login you can get user's information for that token by sending a simple GET request to the following URL:https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=YOUR_GOOGLE_TOKEN
The response differs based on the given scope on the first login step. Mine was set to the below:
https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
#google #login_with_google #oauth #scope #userinfo #oauth2