Snippets Collections
.wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 10px;
  grid-auto-rows: minmax(100px, auto);
}
.one {
  grid-column: 1 / 3;
  grid-row: 1;
}
.two { 
  grid-column: 2 / 4;
  grid-row: 1 / 3;
}
.three {
  grid-column: 1;
  grid-row: 2 / 5;
}
.four {
  grid-column: 3;
  grid-row: 3;
}
.five {
  grid-column: 2;
  grid-row: 4;
}
.six {
  grid-column: 3;
  grid-row: 4;
}
var express = require("express");
var app = express();
const session = require('express-session');
var MemcachedStore = require('connect-memjs')(session);

// configure sessions
var store = new MemcachedStore({servers: [process.env.MEMCACHEDCLOUD_SERVERS], username: process.env.MEMCACHEDCLOUD_USERNAME, password: process.env.MEMCACHEDCLOUD_PASSWORD});
app.use(session({ secret: 'keyboard cat',
   resave: true,
   saveUninitialized: true,
   cookie: { secure: true }, 
   store: store
}))
List<String> songList = new ArrayList<>();
songList.add("Some song"); //Repeat until satisfied

System.out.println("\n\tWelcome! Please choose a song!");
String songChoice = scan.nextLine();
while (!songList.contains(songChoice)) {
    //Do stuff when input is not a recognised song
}
The TypeConverter class is under namespace CsvHelper.TypeConversion

The TypeConverterAttribute is under namespace CsvHelper.Configuration.Attributes

    public class ToIntArrayConverter : TypeConverter
    {
        public override object ConvertFromString(string text, IReaderRow row, MemberMapData memberMapData)
        {
            string[] allElements = text.Split(',');
            int[] elementsAsInteger = allElements.Select(s => int.Parse(s)).ToArray();
            return new List<int>(elementsAsInteger);
        }

        public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
        {
            return string.Join(',', ((List<int>)value).ToArray());
        }
    }
To use this converter, simply add the following TypeConverterAttribute annotations on top of your properties:
To use this converter, simply add the following TypeConverterAttribute annotations on top of your properties:

    public class Names
    {
        [Name("name")]
        public string Name { get; set; }

        [Name("numbersA")]
        [TypeConverter(typeof(ToIntArrayConverter))]
        public List<int> NumbersA { get; set; }

        [Name("numbersB")]
        [TypeConverter(typeof(ToIntArrayConverter))]
        public List<int> NumbersB { get; set; }
    }
<style>

 .circle:before {
                    content: ' \25CF';
                    font-size: 50px;
                    color: black;
                }
</style>

<span class="circle"></span>
add_filter( 'woocommerce_available_payment_gateways', 'conditionally_disable_cod_payment_method', 10, 1);
function conditionally_disable_cod_payment_method( $gateways ){
    // HERE define your Products IDs
    $products_ids = array(2880);

    // Loop through cart items
    foreach ( WC()->cart->get_cart() as $cart_item ){
        // Compatibility with WC 3+
        $product_id = version_compare( WC_VERSION, '3.0', '<' ) ? $cart_item['data']->id : $cart_item['data']->get_id();
        if (in_array( $cart_item['product_id'], $products_ids ) ){
            unset($gateways['cod']);
            break; // As "COD" is removed we stop the loop
        }
    }
    return $gateways;
}
from datetime import datetime

datetime_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')
import 'package:flutter/material.dart';

void main() {
  runApp(
    new MaterialApp(
      title: 'Hello World App',
      home: new myApp(),
    )
  );
}

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Hello World App'),
      ),
      body: new Center(
        child: new Text(
          'Hello, world!'
        ),
      ),
    );
  }
}
double AttackerSuccessProbability(double q, int z)
{
    double p = 1.0 - q;
    double lambda = z * (q / p);
    double sum = 1.0;
    int i, k;
    for (k = 0; k <= z; k++)
    {
        double poisson = exp(-lambda);
        for (i = 1; i <= k; i++)
            poisson *= lambda / i;
        sum -= poisson * (1 - pow(q / p, z - k));
    }
    return sum;
}
<?php 
// PHP program to find nth 
// magic number 

// Function to find nth 
// magic number 
function nthMagicNo($n) 
{ 
	$pow = 1; 
	$answer = 0; 

	// Go through every bit of n 
	while ($n) 
	{ 
	$pow = $pow * 5; 

	// If last bit of n is set 
	if ($n & 1) 
		$answer += $pow; 

	// proceed to next bit 
	$n >>= 1; // or $n = $n/2 
	} 
	return $answer; 
} 

// Driver Code 
$n = 5; 
echo "nth magic number is ", 
	nthMagicNo($n), "\n"; 

// This code is contributed by Ajit. 
?> 
router.post('/:id/edit', auth.requireLogin, (req, res, next) => {
  Post.findByIdAndUpdate(req.params.id, req.body, function(err, post) {
    if(err) { console.error(err) };

     res.redirect(`/`+req.params.id);
  });
});
[[NSProcessInfo processInfo] operatingSystemVersion]
function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();

}
img {
  mask-image: url(‘mask.png’) linear-gradient(-45deg,
                        rgba(0,0,0,1) 20%, rgba(0,0,0,0) 50%);
  mask-image: url(#masking); /*referencing to the element generated and defined in SVG code*/
} 
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var slug = require('mongoose-slug-generator');

mongoose.plugin(slug);

const pageSchema = new Schema({
    title: { type: String , required: true},
    slug: { type: String, slug: "title" }
});

var Page = mongoose.model('Page', pageSchema);
module.exports = Page;
new_stocks = {symbol: price * 1.02 for (symbol, price) in stocks.items()}

Code language: Python (python)
function my_scripts() {
     if(!is_admin() {
          wp_deregister_script('jquery');
          wp_enqueue_script('jquery', '//code.jquery.com/jquery-latest.min.js');
     }
}
add_action('wp_enqueue_scripts', 'my_scripts');


let now = new Date();
alert( now ); // показывает текущие дату и время
<h3>Email</h3>
<div class="py-1">
    <input class="p-1 br-1 email-input" type="email" placeholder="@email">
</div>
<h3>Password</h3>
<div class="py-1">
    <input class="p-1 br-1 password-input" type="password" placeholder="password">
</div>
<h3>Ranges</h3>
<div class="py-1">
    <input class="p-1 range-input" type="range">
</div>
<h3>Radio buttons</h3>
<div class="py-1">
    <input class="p-2 radio-btn" type="radio"><span class="px-1">Option one is this and that—be sure to include why it's great</span>
</div>
<h3>Checkboxes</h3>
<div class="py-1">
    <input class="p-2 radio-btn" type="checkbox"><span class="px-1">Default checkbox</span>
</div>
<div class="py-1">
    <input class="p-1 btn-primary" type="submit">
</div>
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    TextBox1.Text = "Bernard" + vbTab + "32"
    TextBox2.Text = "Luc" + vbTab + "47"
    TextBox3.Text = "François-Victor" + vbTab + "12"
End Sub
def generateParenthesis(n):
    #only add parentehsis if openN < n 
    #only add close parenthesis if closeN < openN 
    #valid if open == closed == n 

    stack = []
    res = []
    
    def backtrack(openN, closeN): 
        if openN == closeN == n: 
            res.append("".join(stack))
            return 
        if openN < n: 
            stack.append('(')
            backtrack(openN + 1, closeN)
            stack.pop()
        if closeN < openN: 
            stack.append(")")
            backtrack(openN, closeN + 1)
            stack.pop()
        #stack.pop() is necessary to clean up stack and come up with other solutions 
        
    backtrack(0, 0)
    #concept is you build openN, closeN but initially, they are at 0 
    return res 

generateParenthesis(3)
import streamlit as st

st.header('''Temperature Conversion App''')

st.write('''Slide to convert value to Fahrenheit''')
value = st.slider('Temperature in Fahrenheit')

st.write(value, '°F is ', (value * 9/5) + 32, '°C')

#Converting temperature to Fahrenheit
st.write('''Slide to convert value to Fahrenheit''')
value = st.slider('Temperature in Celcius')

st.write(value, '° is ', (value - 32) * 5/9, '°C')
//Complete the method that takes a boolean value and return a "Yes" string for true, or a "No" string for false.

function boolToWord( bool ){
const str = bool === true ? "Yes" : "No"
return str
  }
.text-gradient {
    background: linear-gradient(94.23deg,#5374fa 12.41%,#fd9179 52.55%,#ff6969 89.95%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,min=0,sum=0,k=0;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];	
	}
	    for(int i=0;i<n-1;i++)
		sum = sum + pow(abs(a[i] - a[i+1]),2);
		
		min = sum;
	
	    int b[n-1];
	
		for(int i=0;i<n-1;i++)
		{
			b[i] = (a[i] + a[i+1])/2;

		}
		int tt = 1;
	vector<vector<int> > d;
	int qwe=0;
	for(int i=0;i<n-1;i++)
	{
	    vector<int> v;
	for(int j=0;j<n;j++)
	{
	    	if((j == tt) && qwe ==0)
	    	{
			v.push_back(b[tt-1]);
			j--;
			qwe = 1;
	    	}
			else
	        v.push_back(a[j]);
	}
	tt++;
	qwe=0;
	d.push_back(v);
	}
	
			sum = 0;
			for(int i=0;i<n-1;i++)
			{
					for(int j=0;j<=n-1;j++)
					{
					    	sum = sum + pow(abs(d[i][j] - d[i][j+1]),2);
					}
					if(sum < min)
					min = sum;
					
					sum = 0;
			}
			
			cout << min;
	
}
class Solution{
    //Function to count the frequency of all elements from 1 to N in the array.
    public static void frequencyCount(int arr[], int N, int P)
    {
        //Decreasing all elements by 1 so that the elements
        //become in range from 0 to n-1.
        int maxi = Math.max(P,N);
        int count[] = new int[maxi+1];
        Arrays.fill(count, 0);
        for(int i=0;i<N;i++){
            count[arr[i]]++; 
        }
        
        for(int i=0;i<N;i++){
            arr[i] = count[i+1];
        }
    }
}
import java.io.*;
import java.util.*;

class GFG 
{
	static int maxCuts(int n, int a, int b, int c)
	{
		if(n == 0) return 0;
		if(n < 0)  return -1;

		int res = Math.max(maxCuts(n-a, a, b, c), 
		          Math.max(maxCuts(n-b, a, b, c), 
		          maxCuts(n-c, a, b, c)));

		if(res == -1)
			return -1;

		return res + 1; 
	}
  
    public static void main(String [] args) 
    {
    	int n = 5, a = 2, b = 1, c = 5;
    	
    	System.out.println(maxCuts(n, a, b, c));
    }
}
from pandas_profiling import ProfileReport
profile = ProfileReport(df, title="Pandas Profiling Report")
profile.to_file("your_report.html")
wsl --shutdown
diskpart
# open window Diskpart
select vdisk file="C:\WSL-Distros\…\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
const buff_to_base64 = (buff) => btoa(String.fromCharCode.apply(null, buff));

const base64_to_buf = (b64) =>
  Uint8Array.from(atob(b64), (c) => c.charCodeAt(null));

const enc = new TextEncoder();
const dec = new TextDecoder();

const getPasswordKey = (password) =>
  window.crypto.subtle.importKey("raw", enc.encode(password), "PBKDF2", false, [
    "deriveKey",
  ]);

const deriveKey = (passwordKey, salt, keyUsage) =>
  window.crypto.subtle.deriveKey(
    {
      name: "PBKDF2",
      salt: salt,
      iterations: 250000,
      hash: "SHA-256",
    },
    passwordKey,
    {
      name: "AES-GCM",
      length: 256,
    },
    false,
    keyUsage
  );

export async function encrypt(secretData, password) {
  try {
    const salt = window.crypto.getRandomValues(new Uint8Array(16));
    const iv = window.crypto.getRandomValues(new Uint8Array(12));
    const passwordKey = await getPasswordKey(password);
    const aesKey = await deriveKey(passwordKey, salt, ["encrypt"]);
    const encryptedContent = await window.crypto.subtle.encrypt(
      {
        name: "AES-GCM",
        iv: iv,
      },
      aesKey,
      enc.encode(secretData)
    );

    const encryptedContentArr = new Uint8Array(encryptedContent);
    let buff = new Uint8Array(
      salt.byteLength + iv.byteLength + encryptedContentArr.byteLength
    );
    buff.set(salt, 0);
    buff.set(iv, salt.byteLength);
    buff.set(encryptedContentArr, salt.byteLength + iv.byteLength);
    const base64Buff = buff_to_base64(buff);
    return base64Buff;
  } catch (e) {
    console.log(`Error - ${e}`);
    return "";
  }
}

export async function decrypt(encryptedData, password) {
  const encryptedDataBuff = base64_to_buf(encryptedData);
  const salt = encryptedDataBuff.slice(0, 16);
  const iv = encryptedDataBuff.slice(16, 16 + 12);
  const data = encryptedDataBuff.slice(16 + 12);
  const passwordKey = await getPasswordKey(password);
  const aesKey = await deriveKey(passwordKey, salt, ["decrypt"]);
  const decryptedContent = await window.crypto.subtle.decrypt(
    {
      name: "AES-GCM",
      iv: iv,
    },
    aesKey,
    data
  );
  return dec.decode(decryptedContent);
}
#watch-page-skeleton{position:relative;z-index:1;margin:0 auto;box-sizing:border-box}#watch-page-skeleton #info-container,#watch-page-skeleton #related{box-sizing:border-box}.watch-skeleton .text-shell{height:20px;border-radius:2px}.watch-skeleton .skeleton-bg-color{background-color:hsl(0,0%,89%)}.watch-skeleton .skeleton-light-border-bottom{border-bottom:1px solid hsl(0,0%,93.3%)}html[dark] .watch-skeleton .skeleton-bg-color{background-color:hsl(0,0%,16%)}html[dark] .watch-skeleton .skeleton-light-border-bottom{border-bottom:1px solid hsla(0,100%,100%,.08)}.watch-skeleton .flex-1{-ms-flex:1;-webkit-flex:1;flex:1;-webkit-flex-basis:.000000001px;flex-basis:.000000001px}.watch-skeleton #primary-info{height:64px;padding:20px 0 8px}.watch-skeleton #primary-info #title{width:400px;margin-bottom:12px}.watch-skeleton #primary-info #info{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;-webkit-align-items:center;align-items:center}.watch-skeleton #primary-info #info #count{width:200px}.watch-skeleton #primary-info #info #menu{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;padding-right:8px}.watch-skeleton #primary-info .menu-button{height:20px;width:20px;border-radius:50%;margin-left:20px}.watch-skeleton #secondary-info{height:151px;margin-bottom:24px;padding:16px 0}.watch-skeleton #secondary-info #top-row,.watch-skeleton #secondary-info #top-row #video-owner{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row}.watch-skeleton #secondary-info #top-row #video-owner #channel-icon{height:48px;width:48px;border-radius:50%;margin-right:16px}.watch-skeleton #secondary-info #top-row #video-owner #upload-info{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.watch-skeleton #secondary-info #top-row #video-owner #upload-info #owner-name{width:200px;margin-bottom:12px}.watch-skeleton #secondary-info #top-row #video-owner #upload-info #published-date{width:200px}.watch-skeleton #secondary-info #top-row #subscribe-button{width:137px;height:36px;border-radius:2px;margin:7px 4px 0 0}#watch-page-skeleton #related{float:right;position:relative;clear:right;max-width:426px;width:calc(100% - 640px)}#watch-page-skeleton.theater #related{width:100%}.watch-skeleton #related .autoplay{margin-bottom:16px}.watch-skeleton #related[playlist] .autoplay{border-bottom:none;margin-bottom:0}.watch-skeleton #related #upnext{height:20px;width:120px;margin-bottom:14px}.watch-skeleton #related[playlist] #upnext{display:none}.watch-skeleton #related .video-details{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;padding-bottom:8px}.watch-skeleton #related:not([playlist]) .autoplay .video-details{padding-bottom:16px}.watch-skeleton #related .video-details .thumbnail{height:94px;width:168px;margin-right:8px}.watch-skeleton #related .video-details .video-title{width:200px;margin-bottom:12px}.watch-skeleton #related .video-details .video-meta{width:120px}@media (max-width:999px){#watch-page-skeleton{width:854px}#watch-page-skeleton #container{display:-moz-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column}#watch-page-skeleton #info-container{order:1}#watch-page-skeleton #related{order:2;width:100%;max-width:100%}}@media (max-width:856px){#watch-page-skeleton{width:640px}}@media (max-width:656px){#watch-page-skeleton{width:426px}}@media (min-width:882px){#watch-page-skeleton.theater{width:100%;max-width:1706px;padding:0 32px}#watch-page-skeleton.theater #related{margin-top:0}#watch-page-skeleton.theater #info-container>*{margin-right:24px}}@media (min-width:1000px){#watch-page-skeleton{width:100%;max-width:1066px}#watch-page-skeleton #related{margin-top:-360px;padding-left:24px}#watch-page-skeleton #info-container{width:640px}#watch-page-skeleton.theater #info-container{width:100%;padding-right:426px}}@media (min-width:1294px) and (min-height:630px){#watch-page-skeleton{width:100%;max-width:1280px}#watch-page-skeleton #related{margin-top:-480px}#watch-page-skeleton #info-container{width:854px}}@media (min-width:1720px) and (min-height:980px){#watch-page-skeleton{width:100%;max-width:1706px}#watch-page-skeleton #related{margin-top:-720px}#watch-page-skeleton #info-container{width:1280px}}#watch-page-skeleton.theater.theater-all-widths{width:100%;max-width:1706px;padding:0 32px}#watch-page-skeleton.theater.theater-all-widths #related{margin-top:0}#watch-page-skeleton.theater.theater-all-widths #info-container>*{margin-right:24px}#watch-page-skeleton #related{display:none}
val sheetState = rememberModalBottomSheetState(
    initialValue = ModalBottomSheetValue.Hidden,
    confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded }
)
git log --all --graph --decorate
// models.py
from django.db.models.fields import FloatField

class Product(models.Model):
    title = models.CharField(max_length=225)
    price = models.FloatField()
    discount_percent = FloatField(default=0) # Assigning it a default value of 0 so it doesn't throw a 'NoneType' error when it's null.
  
    @property
    def discount(self):
        if self.discount_percent > 0:
            discounted_price = self.price - self.price * self.discount_percent / 100
            return discounted_price

class OrderItem(models.Model):
    product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
    order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
    quantity = models.IntegerField(default=0, null=True, blank=True)
	
	# get_total function has to be updated too to calculate using the correct current price
    @property
    def get_total(self):
        if self.product.discount_percent > 0:
            price_now = self.product.price - self.product.price * self.product.discount_percent / 100
        else:
            price_now = self.product.price

        total = price_now * self.quantity
        return total

// Your template
{% if product.discount_percent %}
                <h4 class="product__price--original">₾{{ product.price|floatformat:2 }}</h4>
                <h4 class="product__price--discounted">₾{{ product.discount|floatformat:2 }}</h4>
                {% else %}  
                <h4>₾{{ product.price|floatformat:2 }}</h4>
                {% endif %}
                
// Here's some Sass too, if you need it
.product__price {
  &--original {
    text-decoration: line-through;
  }
  &--discounted {
    color: green;
  }
}
const { useState } = React;

function PageComponent() {
  const [count, setCount] = useState(0);
  const increment = () => {
    setCount(count + 1)
  }

  return (
    <div className="App">
      <ChildComponent onClick={increment} count={count} />         
      <h2>count {count}</h2>
      (count should be updated from child)
    </div>
  );
}

const ChildComponent = ({ onClick, count }) => {
  return (
    <button onClick={onClick}>
       Click me {count}
    </button>
  )
};

ReactDOM.render(<PageComponent />, document.getElementById("root"));
{
    // Debugger Tool for Firefox has to be installed: https://github.com/firefox-devtools/vscode-firefox-debug
    // And Remote has to be enabled: https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Debugging_Firefox_Desktop#enable_remote_debugging
    "version": "0.2.0",
    "configurations": [
        {
            "type": "firefox",
            "request": "launch",
            "name": "Launch Firefox against localhost",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "enableCRAWorkaround": true,
            "reAttach": true,
            "reloadOnAttach": true,
            "reloadOnChange": {
                "watch": "${workspaceFolder}/**/*.ts",
                "ignore": "**/node_modules/**"
            }
        }
    ]
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
...
...
AlertDialog dialog = builder.create();

ColorDrawable back = new ColorDrawable(Color.TRANSPARENT);
InsetDrawable inset = new InsetDrawable(back, 20);
dialog.getWindow().setBackgroundDrawable(inset);

dialog.show();
.LikeButton button {
  margin: 1rem;
  transition: all 0.5s ease;
  transform: scale(1);
}

.LikeButton button:hover {
  cursor: pointer;
  transform: scale(1.25);
  filter: brightness(120%);
}
const comparePassword = async (password, hash) => {
    try {
        // Compare password
        return await bcrypt.compare(password, hash);
    } catch (error) {
        console.log(error);
    }

    // Return false if error
    return false;
};

//use case
(async () => {
    // Hash fetched from DB
    const hash = `$2b$10$5ysgXZUJi7MkJWhEhFcZTObGe18G1G.0rnXkewEtXq6ebVx1qpjYW`;

    // Check if password is correct
    const isValidPass = await comparePassword('123456', hash);

    // Print validation status
    console.log(`Password is ${!isValidPass ? 'not' : ''} valid!`);
    // => Password is valid!
})();
import pickle
import os
from google_auth_oauthlib.flow import Flow, InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload
from google.auth.transport.requests import Request


def Create_Service(client_secret_file, api_name, api_version, *scopes):
    print(client_secret_file, api_name, api_version, scopes, sep='-')
    CLIENT_SECRET_FILE = client_secret_file
    API_SERVICE_NAME = api_name
    API_VERSION = api_version
    SCOPES = [scope for scope in scopes[0]]
    print(SCOPES)

    cred = None

    pickle_file = f'token_{API_SERVICE_NAME}_{API_VERSION}.pickle'
    # print(pickle_file)

    if os.path.exists(pickle_file):
        with open(pickle_file, 'rb') as token:
            cred = pickle.load(token)

    if not cred or not cred.valid:
        if cred and cred.expired and cred.refresh_token:
            cred.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
            cred = flow.run_local_server()

        with open(pickle_file, 'wb') as token:
            pickle.dump(cred, token)

    try:
        service = build(API_SERVICE_NAME, API_VERSION, credentials=cred)
        print(API_SERVICE_NAME, 'service created successfully')
        return service
    except Exception as e:
        print('Unable to connect.')
        print(e)
        return None

def convert_to_RFC_datetime(year=1900, month=1, day=1, hour=0, minute=0):
    dt = datetime.datetime(year, month, day, hour, minute, 0).isoformat() + 'Z'
    return dt
dd_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
/* * custom_woocommerce_template_loop_add_to_cart**/
function custom_woocommerce_product_add_to_cart_text() {	
global $product;		
  $product_type = $product->get_type();		switch ( $product_type ) {		case 'external':			return _( 'Buy product', 'woocommerce' );		break;		case 'grouped':			return _( 'View products', 'woocommerce' );		break;		case 'simple':			return _( 'Add to cart', 'woocommerce' );		break;		case 'variable':			return _( 'Select options', 'woocommerce' );		break;		default:			return __( 'Read more', 'woocommerce' );	}	}
[
   {
      "mostrar":"in,out",
      "label":"CURSO DE FORMAÇÃO EM TERAPEUTA AYURVEDA",
      "campo":"cursotitulo",
      "tipo":"titulo6",
      "colunas_in":"12",
      "colunas_out":"12"
   },
   {
      "mostrar":"in,out",
      "label":"Nome Completo",
      "campo":"nomecompleto",
      "tipo":"text",
      "colunas_in":"12",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Data de nascimento",
      "campo":"data_nasc",
      "tipo":"data",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"CPF",
      "campo":"nrocpf",
      "tipo":"cpf",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Estado Civil",
      "campo":"estado_civil",
      "tipo":"select_valor",
      "colunas_in":"6",
      "colunas_out":"4",
      "opcoes":[
         "Casado",
         "Solteiro",
         "Separado",
         "Viuvo"
      ],
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Profissão",
      "campo":"profi",
      "tipo":"text",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Email",
      "campo":"email",
      "tipo":"text",
      "colunas_in":"12",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Telefone Celular",
      "campo":"telcelular",
      "tipo":"text",
      "placeholder":"(xx) x xxxx-xxxx",
      "colunas_in":"6",
      "colunas_out":"6",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Telefone Residencial",
      "campo":"telresidencial",
      "tipo":"text",
      "placeholder":"(xx) x xxxx-xxxx",
      "colunas_in":"6",
      "colunas_out":"6"
   },
   {
      "mostrar":"in,out",
      "label":"Endereço",
      "campo":"logradouro",
      "tipo":"text",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"Cidade",
      "campo":"cid",
      "tipo":"text",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"CEP",
      "campo":"cep_user",
      "tipo":"text",
      "colunas_in":"6",
      "colunas_out":"4",
      "requerido":"1"
   },
   {
      "mostrar":"in,out",
      "label":"PAGAMENTO",
      "campo":"pagamento",
      "tipo":"titulo6",
      "colunas_in":"12",
      "colunas_out":"12"
   },
   {
      "mostrar":"in,out",
      "label":"Forma de Pagamento",
      "campo":"forma_pagamento",
      "tipo":"select_valor",
      "colunas_in":"6",
      "colunas_out":"6",
      "requerido":"1",
      "opcoes":[
         "À vista",
         "À prazo",
         "Boleto",
         "Cheque"
      ],
      "conditions":[
         {
            "when":"equal",
            "value":"À prazo",
            "action":{
               "show":[
                  "parcelas"
               ],
               "required":[
                  "parcelas"
               ]
            }
         }
      ]
   },
   {
      "mostrar":"in,out",
      "label":"Em quantas parcelas?",
      "campo":"parcelas",
      "tipo":"number",
      "colunas_in":"12",
      "colunas_out":"12",
      "classe":"hide"
   },
   {
      "mostrar":"in,out",
      "label":"Escola",
      "campo":"escola",
      "tipo":"select_valor",
      "colunas_in":"12",
      "colunas_out":"12",
      "requerido":"1",
      "opcoes":[
         "Semente da Paz",
         "Leveza do Ser",
         "Beija Flor",
         "La vie",
         "Karina Gomes"
      ],
      "aceita_recategorizar":"1"
   },
   {
      "mostrar":"in,out",
      "label":"TERMO DE AUTORIZAÇÃO",
      "campo":"termo",
      "tipo":"titulo6",
      "colunas_in":"12",
      "colunas_out":"12"
   },
   {
      "mostrar":"in,out",
      "campo":"autori",
      "tipo":"texto",
      "valor_padrao":"Eu, autorizo a gravar (minha imagem em vídeo ou fotografia) e veicular minha imagem e depoimentos em qualquer meios de comunicação para fins didáticos, de pesquisa e divulgação de conhecimento científico sem quaisquer ônus e restrições. Fica ainda autorizada, de livre e espontânea vontade, para os mesmos fins, a cessão de direitos da veiculação, não recebendo para tanto qualquer tipo de remuneração. ",
      "colunas_in":"12",
      "colunas_out":"12"
   },
   {
      "mostrar":"in,out",
      "label":"Eu concordo e autorizo",
      "campo":"concordancia",
      "tipo":"checkbox",
      "colunas_in":"12",
      "colunas_out":"12",
      "requerido":"1"
   }
]
public <T> List<Class<? extends T>> findAllMatchingTypes(Class<T> toFind) {
    foundClasses = new ArrayList<Class<?>>();
    List<Class<? extends T>> returnedClasses = new ArrayList<Class<? extends T>>();
    this.toFind = toFind;
    walkClassPath();
    for (Class<?> clazz : foundClasses) {
        returnedClasses.add((Class<? extends T>) clazz);
    }
    return returnedClasses;
}
#!/bin/bash
# Bash Menu Script Example

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice 1"
            ;;
        "Option 2")
            echo "you chose choice 2"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Quit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done
--add-metadata --postprocessor-args "-metadata artist=Pink\ Floyd"
star

Mon May 11 2020 21:33:40 GMT+0000 (Coordinated Universal Time) https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout

@Ulises Villa #css

star

Wed Apr 01 2020 11:31:57 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60967832/insert-arraylist-into-while-condition

@SunLoves #java #java #arraylists #while-loops #equala

star

Wed Apr 01 2020 08:42:17 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60966194/using-csvhelper-to-read-cell-content-into-list-or-array

@Anier #C#

star

Mon Mar 02 2020 22:07:43 GMT+0000 (Coordinated Universal Time)

@carlathemarla #css #shapes

star

Thu Feb 06 2020 12:35:11 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/42108036/how-to-disable-cash-on-delivery-on-some-specific-products-in-woocommerce

@karanikolasms #php

star

Wed Jan 22 2020 18:52:28 GMT+0000 (Coordinated Universal Time) https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime

@logicloss01 #python #dates #functions #python3.8

star

Sun Dec 29 2019 19:42:22 GMT+0000 (Coordinated Universal Time) https://kodestat.gitbook.io/flutter/flutter-hello-world

@charter_carter #android #dart #flutter #ios #helloworld

star

Wed Dec 25 2019 13:48:42 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/find-nth-magic-number/

@marshmellow #php #interviewquestions #makethisbetter

star

https://stackoverflow.com/questions/3339722/how-to-check-ios-version

@mishka #ios #swift

star

https://codepen.io/shaikmaqsood/pen/XmydxJ

@mishka #javascript

star

https://www.creativebloq.com/features/css-tricks-to-revolutionise-your-layouts

@mishka #css

star

Wed Feb 28 2024 07:51:24 GMT+0000 (Coordinated Universal Time) https://www.pythontutorial.net/python-basics/python-dictionary-comprehension/

@viperthapa #python

star

Sat Nov 25 2023 07:59:24 GMT+0000 (Coordinated Universal Time) https://www.thepixelpixie.com/how-to-properly-enqueue-jquery-in-a-wordpress-site/

@dmsearnbit #javascript

star

Fri Nov 24 2023 10:05:35 GMT+0000 (Coordinated Universal Time) https://learn.javascript.ru/date

@jimifi4494 #javascript

star

Thu Feb 16 2023 15:18:12 GMT+0000 (Coordinated Universal Time)

@logesh #html

star

Fri Nov 11 2022 18:41:00 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/366124/inserting-a-tab-character-into-text-using-c-sharp

@javicinhio #cs

star

Tue Sep 27 2022 02:03:10 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/generate-parentheses/

@bryantirawan #python #neetcode #parenthesis #open #close

star

Tue Apr 12 2022 13:25:38 GMT+0000 (Coordinated Universal Time)

@Luduwanda #javascriptreact

star

Fri Apr 08 2022 16:10:51 GMT+0000 (Coordinated Universal Time)

@Mazen #css

star

Sun Mar 06 2022 22:14:59 GMT+0000 (Coordinated Universal Time) https://ayushshuklas.blogspot.com

@ayushshuklas

star

Tue Feb 08 2022 05:43:55 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/frequency-of-array-elements-1587115620/1/?track=DSASP-Arrays&batchId=190

@Uttam #java #gfg #geeksforgeeks #arrays #practice #frequencycount #frequencies #limitedrange

star

Sun Feb 06 2022 21:32:20 GMT+0000 (Coordinated Universal Time)

@Uttam #java #gfg #geeksforgeeks #lecture #recursion #rope cutting

star

Wed Jan 26 2022 02:55:52 GMT+0000 (Coordinated Universal Time)

@jmbenedetto #python

star

Mon Dec 27 2021 12:25:33 GMT+0000 (Coordinated Universal Time) https://github.com/microsoft/WSL/issues/4699#issuecomment-627133168

@RokoMetek #bash #powershell

star

Wed Dec 22 2021 03:34:04 GMT+0000 (Coordinated Universal Time) https://explosion-scratch.github.io/blog/0-knowledge-auth/

@Explosion #javascript

star

Sun Dec 19 2021 15:55:17 GMT+0000 (Coordinated Universal Time) https://www.youtube.com/s/desktop/21ad9f7d/cssbin/www-main-desktop-watch-page-skeleton.css

@Devanarayanan12

star

Mon Dec 13 2021 08:42:45 GMT+0000 (Coordinated Universal Time)

@GoodRequest. #kotlin

star

Thu Dec 09 2021 20:15:48 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/57110542/how-to-write-a-nvmrc-file-which-automatically-change-node-version

@richard #sh

star

Wed Nov 17 2021 14:07:48 GMT+0000 (Coordinated Universal Time)

@swina #git

star

Mon Nov 01 2021 11:23:17 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/68015014/flutter-error-filesystemexception-creation-failed-path-storage-emulated-0

@awaisab171 #dart

star

Wed Oct 06 2021 21:25:25 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/55726886/react-hook-send-data-from-child-to-parent-component

@richard #javascript

star

Fri Sep 03 2021 08:50:14 GMT+0000 (Coordinated Universal Time) https://www.matuzo.at/blog/element-diversity/

@gorlanova #css

star

Thu Sep 02 2021 14:15:48 GMT+0000 (Coordinated Universal Time)

@jolo #setting #vscode

star

Sat Jul 03 2021 08:25:15 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/6153489/how-to-set-margins-to-a-custom-dialog

@swalia

star

Wed Jun 30 2021 08:18:15 GMT+0000 (Coordinated Universal Time)

@hisam #css

star

Sun Jun 06 2021 15:47:09 GMT+0000 (Coordinated Universal Time) https://attacomsian.com/blog/nodejs-password-hashing-with-bcrypt

@hisam #bcrypt #authentication #express #nodejs #password

star

Fri Jun 04 2021 07:59:01 GMT+0000 (Coordinated Universal Time) https://learndataanalysis.org/how-to-upload-a-video-to-youtube-using-youtube-data-api-in-python/

@admariner

star

Tue May 18 2021 20:01:30 GMT+0000 (Coordinated Universal Time)

@Shesek

star

Tue May 18 2021 15:14:20 GMT+0000 (Coordinated Universal Time)

@zlucxie #json #premaom

star

Tue May 11 2021 05:06:03 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/9991253/finding-all-classes-implementing-a-specific-interface

@anoopsugur #java

star

Sat Apr 24 2021 21:00:41 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/1705/how-can-i-create-a-select-menu-in-a-shell-script

@LavenPillay #bash

star

Mon Apr 12 2021 03:20:10 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/39885346/youtube-dl-add-metadata-during-audio-conversion

@steadytom

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension