Skip to content

Instantly share code, notes, and snippets.

View shah0150's full-sized avatar

Adesh Shah shah0150

View GitHub Profile
let apiUrl = 'https://jsonplaceholder.typicode.com/todos';
// Data to be uploaded
let postData = {
title: 'Read materials for JS',
completed: false
}
// Options or headers
let options = {
method: 'POST', //using POST to upload my data
headers: {

The behavior you described, where a switch statement continues to execute all statements below a matching case until it encounters a break statement, is indeed by design in JavaScript. This behavior can be both a feature and a potential source of confusion if not used carefully.

The historical reason for this behavior can be traced back to the origins of the switch statement in C and C++. In these languages, the switch statement was designed to provide a compact way to jump to specific sections of code based on the value of an expression. When a matching case was found, control would flow continuously through the subsequent cases unless a break statement was encountered. This behavior made sense in C and C++ because it allowed for more efficient code execution in some cases.

However, in JavaScript, this behavior has been inherited, and it can indeed be a source of confusion for developers who are not familiar with it. To address this, it's generally considered good practice to include break statements after

from ann_visualizer.visualize import ann_viz;
ann_viz(model, title="My first neural network")
@shah0150
shah0150 / index.py
Created April 14, 2018 16:41
Visualizing Artificial Neural Networks (ANNs) with just One Line of Code
# Create your first MLP in Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy
# fix random seed for reproducibility
numpy.random.seed(7)
# load pima indians dataset
dataset = numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")
# split into input (X) and output (Y) variables
X = dataset[:,0:8]
using System.Windows;
using Microsoft.Gestures;
using Microsoft.Gestures.Endpoint;
thumpsUp.Triggered += (sender, args) =>
{
Dispatcher.Invoke(() => Cheers.Text = "Good Job, Project Prague");
};
fist.Triggered += (sender, args) =>
{
Dispatcher.Invoke(() => Cheers.Text = "Show");
};
<TextBox Name="Cheers" HorizontalAlignment="Left" TextAlignment="Center" Height="100" Margin="0,135,0,0" TextWrapping="WrapWithOverflow" Text="" VerticalAlignment="Top" Width="519" FontSize="25" />
var gesturesService = GesturesServiceEndpointFactory.Create();
await gesturesService.ConnectAsync();
await gesturesService.RegisterGesture(thumpsUp);
var fist = new HandPose("Fist", new FingerPose(new AllFingersContext(), FingerFlexion.Folded));
var cheers = new HandPose("ThumpsUp",
new FingerPose(new[] { Finger.Thumb }, FingerFlexion.Open),
new FingerPose(new[] { Finger.Index, Finger.Ring, Finger.Pinky, Finger.Middle }, FingerFlexion.Folded));
var thumpsUp = new Gesture("thumpsUp", fist, cheers);