Posts

Showing posts from October, 2007

A Cookie Associated With A Cross-site Resource At Http://134tow.com.au/ Was Set Without The `SameSite` Attribute Code Example

Example: A cookie associated with a cross-site resource at http://placeholder.com/ was set without the `SameSite` attribute. response . setHeader ( "Set-Cookie" , "HttpOnly;Secure;SameSite=Strict" ) ;

Bootstrap Button Primary Color Code Code Example

Example 1: bootstarp btn colors < button type = "button" class = "btn btn-primary" > Blue < /button > < button type = "button" class = "btn btn-secondary" > Grey < /button > < button type = "button" class = "btn btn-success" > Green < /button > < button type = "button" class = "btn btn-danger" > Red < /button > < button type = "button" class = "btn btn-warning" > Yellow < /button > < button type = "button" class = "btn btn-info" > Ligth blue < /button > < button type = "button" class = "btn btn-light" > White < /button > < button type = "button" class = "btn btn-dark" > Black < /button > < button type = "button" class = "btn btn-link" > White with blue text < /button > Example 2:

Angry Ip Scanner Download Code Example

Example: Angry IP Scanner It's an IP Scanner to find open ports in the server and vulnerabelities

Adding Search Functionality In Select Options Using Bootstrap

Answer : To get a search functionality you must set the data-tokens attribute for each options. Here is your code after adding it. Let me know if you need additional help. $(function() { $('.selectpicker').selectpicker(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet" /> <div class="container"> <div class="row"> <div class="col-xs-12

All Keycodes Unity Code Example

Example 1: unity keycode if ( Input . GetKeyDown ( KeyCode . A ) ) { Debug . Log ( "The A key was pressed." ) ; } Example 2: unity getkey keycode Input . GetKey ( KeyCode . Space ) )

100x100 Image With Random Pixel Colour

Image
Answer : This is simple with numpy and pylab . You can set the colormap to be whatever you like, here I use spectral. from pylab import imshow, show, get_cmap from numpy import random Z = random.random((50,50)) # Test data imshow(Z, cmap=get_cmap("Spectral"), interpolation='nearest') show() Your target image looks to have a grayscale colormap with a higher pixel density than 100x100: import pylab as plt import numpy as np Z = np.random.random((500,500)) # Test data plt.imshow(Z, cmap='gray', interpolation='nearest') plt.show() If you want to create an image file (and display it elsewhere, with or without Matplotlib), you could use NumPy and Pillow as follows: import numpy, from PIL import Image imarray = numpy.random.rand(100,100,3) * 255 im = Image.fromarray(imarray.astype('uint8')).convert('RGBA') im.save('result_image.png') The idea here is to create a numeric array, convert it to a RGB image, and sa

Python Convert Binary To Image Code Example

Example 1: convert image to binary python img = cv2 . imread ( '<image path>' ) gray_img = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) Example 2: generate binay image python import numpy as np from numpy import random # Generating an image of values between 1 and 255. im_thresh = random . randint ( 1 , 256 , ( 64 , 64 ) ) # Set anything less than 255 to 0. Unnecessary if cv2 does this during threshold . # Must go before the operation below in order not to set all values to 0. im_thresh [ im_thresh < 255 ] = 0 # Set all values at indices where the array equals 255 to 1. im_thresh [ im_thresh == 255 ] = 1

Bash Not Equal String Code Example

Example 1: greater than in script -eq is equal to if [ "$a" -eq "$b" ] -ne is not equal to if [ "$a" -ne "$b" ] -gt is greater than if [ "$a" -gt "$b" ] -ge is greater than or equal to if [ "$a" -ge "$b" ] -lt is less than if [ "$a" -lt "$b" ] -le is less than or equal to if [ "$a" -le "$b" ] Example 2: test string equality bash strval1="Ubuntu" strval2="Windows" #Check equality two string variables if [ $strval1 == $strval2 ]; then echo "Strings are equal" else echo "Strings are not equal" fi #Check equality of a variable with a string value if [ $strval1 == "Ubuntu" ]; then echo "Linux operating system" else echo "Windows operating system" fi

Animated Widget Flutter Code Example

Example: Animation Flutter class _WelcomeScreenState extends State < WelcomeScreen > with SingleTickerProviderStateMixin { AnimationController controller; Animation animation; @override void initState() { super.initState(); controller = AnimationController( duration: Duration(seconds: 1), vsync: this, ); animation = ColorTween(begin: Colors.blueGrey, end: Colors.white) .animate(controller); controller.forward(); controller.addListener(() { setState(() {}); print(animation.value); }); }

Bootstrap Navbar-toggler-icon Code Example

Example 1: bootstrap navbar toggler icon color .custom-toggler .navbar-toggler-icon { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,102,203, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E"); } .custom-toggler.navbar-toggler { border-color: rgb(255,102,203); } Example 2: bootstrap navbar < nav class = " navbar navbar-expand-lg navbar-light bg-light " > < a class = " navbar-brand " href = " # " > Navbar </ a > < button class = " navbar-toggler " type = " button " data-toggle = " collapse " data-target = " #navbarNavAltMarkup " aria-controls = " navbarNavAltMarkup " aria-expanded = " false " aria-label = " Toggle navigation

Bash Foreach Loop

Answer : Something like this would do: xargs cat <filenames.txt The xargs program reads its standard input, and for each line of input runs the cat program with the input lines as argument(s). If you really want to do this in a loop, you can: for fn in `cat filenames.txt`; do echo "the next file is $fn" cat $fn done "foreach" is not the name for bash. It is simply "for". You can do things in one line only like: for fn in `cat filenames.txt`; do cat "$fn"; done Reference: http://www.cyberciti.biz/faq/linux-unix-bash-for-loop-one-line-command/ Here is a while loop: while read filename do echo "Printing: $filename" cat "$filename" done < filenames.txt

How To Convert Char To Int In Cpp Code Example

Example 1: char to int c++ int x = ( int ) character - 48 ; Example 2: char* to int in cpp int x = std :: stoi ( "42" ) Example 3: converting char to integer c++ int x = '9' - 48 ; // x now equals 9 as an integer Example 4: convert char to int c++ int x = character - '0' Example 5: converting char to int in c++ # include <sstream> using namespace std ; int main ( ) { stringstream str ; str << "1" ; double x ; str >> x ; }

How Can I Download Just Mp3 Using Youtube-dl? Code Example

Example: how to use youtube dl for mp3 youtube - dl - x -- audio - format mp3 https : //www.youtube.com/watch?v=jwD4AEVBL6Q

Array Pop Php First Code Example

Example: how to remove first element in array php <?php $stack = array ( "orange" , "banana" , "apple" , "raspberry" ) ; $fruit = array_shift ( $stack ) ; print_r ( $stack ) ; ?> // Array // ( // [0] => banana // [1] => apple // [2] => raspberry // )

Codeigniter Get Value From Url Code Example

Example: get current url in codeigniter simple get like this echo $this->input->get('my_id'); Load the URL helper To get current url $currentURL = current_url(); //http://myhost/main $params = $_SERVER['QUERY_STRING']; //my_id=1,3 $fullURL = $currentURL . '?' . $params; echo $fullURL; //http://myhost/main?my_id=1,3

Blender Text Editor Change Text Cursor Code Example

Example: blender change text during animation import bpy scene = bpy . context . scene obj = scene . objects [ 'Text' ] def recalculate_text ( scene ) : obj . data . body = 'Current frame: ' + str ( scene . frame_current ) bpy . app . handlers . frame_change_pre . append ( recalculate_text )

C++ Uint 8 Code Example

Example: c++ uint32_t // uint32_t is a type definition for a 32 bit unsigned integer typedef unsigned int uint32_t unsigned int myInt ; // Same as uint32_t myInt ;

40 Second Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Auto Format Code Android Studio Code Example

Example: auto format android studio Cmd+Alt+L (on Mac) Ctrl+Alt+L (on Windows and Linux)

Chartjs Tooltip Line Breaks

Answer : If you are using 2.0.0-beta2, you can use tooltip callback and return array of strings there. tooltips: { mode: 'single', callbacks: { afterBody: function(data) { var multistringText = ['first string']; // do some stuff multistringText.push('another string'); return multistringText; } } } Actually all tool-tip callbacks support multiple lines of text, and you can use label callback as usual. It renders data label as tool-tip text by default. Quoted from documentation: All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text. Example code: tooltips: { callbacks: { label: (tooltipItem, data) => { if (tooltipItem.index % 2) return ['Item 1', 'Item 2', 'Item 3']; else return 'Single line'; } } } You can use

Android: How To Initialize A Variable Of Type "Location" (other Than Making It Equal To Null)

Answer : The API documentation is quite clear on this. First create a new Location instance: Location loc = new Location("dummyprovider"); And then use the setter methods to set the location parameters you need, e.g.: loc.setLatitude(20.3); loc.setLongitude(52.6); Location object = new Location("service Provider"); it will create an object of Type Location that contains the initial Latitude and Longitude at location '0' to get the initial values use double lat = object.getLatitude(); double lng = object.getLongitude(); In Kotlin using LocationManager class you can pass the required location provider like: val location = Location(LocationManager.NETWORK_PROVIDER) // OR GPS_PROVIDER based on the requirement location.latitude = 42.125 location.longitude = 55.123