Posts

Showing posts from October, 2010

Array Join Php Code Example

Example 1: php array join $arr = array ( 'Hello' , 'World!' , 'Beautiful' , 'Day!' ) ; echo join ( ", " , $arr ) ; Example 2: join array of strings php $arr = array ( 'Hello' , 'World!' , 'Beautiful' , 'Day!' ) ; echo join ( "," , $arr ) ; Example 3: php join array Definition and Usage The join() function returns a string from the elements of an array. The join() function is an alias of the implode() function. Note: The join() function accept its parameters in either order. However, for consistency with explode(), you should use the documented order of arguments. Note: The separator parameter of join() is optional. However, it is recommended to always use two parameters for backwards compatibility. Syntax join(separator,array) Example Join array elements with a string: <?php $arr = array ( 'Hello' , 'World!' , 'Beautiful' , 'Day!' ) ; echo

Can Ping IP Address And Nslookup Hostname But Cannot Ping Hostname Temporarily In Windows

Answer : I faced the same problem in my network. When you use this command: ping icecream It uses WINS server since you have used icecream not icecream.my.domain . When looking for such words, Windows looks for NETBIOS names, but when you look for complete domain records, it will look in the DNS server. You can use one of the solutions below: Make sure you have correct records for that station in your WINS server. Use the complete domain name instead of using the host file. E.g. icecream.my.domain You don't have DNS suffixes configured. Either configure them, or use FQDN like this and it should work: ping icecream.my.domain

Matplotlib Plot Color Code Example

Example 1: change plot line color in matplotlib plot ( x , y , color = 'green' , linestyle = 'dashed' , marker = 'o' , markerfacecolor = 'blue' , markersize = 12 ) . Example 2: change graph colors python matplotlib plt . plot ( [ values ] , color = 'color' ) Example 3: matplotlib color Alias Color 'b' blue 'g' green 'r' red 'c' cyan 'm' magenta 'y' yellow 'k' black 'w' white

Bind Scroll Jump Code Example

Example: csgo mouse wheel jump bind bind mwheelup + jump ; bind mwheeldown + jump ; bind space + jump

Change Background Image Opacity

Answer : Nowadays, it is possible to do it simply with CSS property "background-blend-mode" . <div id="content">Only one div needed</div> div#content { background-image: url(my_image.png); background-color: rgba(255,255,255,0.6); background-blend-mode: lighten; /* You may add things like width, height, background-size... */ } It will blend the background-color (which is white, 0.6 opacity) into the background image. Learn more here (W3S). You can't use transparency on background-images directly, but you can achieve this effect with something like this: http://jsfiddle.net/m4TgL/ HTML: <div class="container"> <div class="content">//my blog post</div> </div>​ CSS: .container { position: relative; } .container:before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1; background-image: url('i

Bootstrap Label And Input Code Example

Example 1: bootsrap label <span class= "label label-default" >Default Label</span> <span class= "label label-primary" >Primary Label</span> <span class= "label label-success" >Success Label</span> <span class= "label label-info" >Info Label</span> <span class= "label label-warning" >Warning Label</span> <span class= "label label-danger" >Danger Label</span> Example 2: bootstrap radio <div class= "form-check form-check-inline" > <input class= "form-check-input" type= "radio" name= "inlineRadioOptions" id= "inlineRadio1" value= "option1" > <label class= "form-check-label" for= "inlineRadio1" > 1 </label> </div> <div class= "form-check form-check-inline" > <input class= "form-check-input" type= "radi

Ajax File Upload With Form Data Laravel 5.3

Answer : Try using the FormData in ajax while you upload a file. Just try this $('form').submit(function(event) { event.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ url: '{{ url('/agents') }}', type: 'POST', data: formData, success: function(result) { location.reload(); }, error: function(data) { console.log(data); } }); }); OR You can try with this jQuery library https://github.com/malsup/form EDIT public function store(Request $request) { if (User::where('phone_number', '=', Input::get('phone_number'))->exists()) { return $this->respondBadRequest('Phone Number Exists'); } else { $user=User::create($request->all()); if($request->hasFile('image')) { $file = $request->file('i

Addgroup Vs Groupadd

Answer : On most distribution adduser and addgroup are interactive 'convenience' wrappers around the commands useradd and groupadd . You can find addgroup using the command which addgroup , on my machine (Ubuntu 11.04) this lives in /usr/sbin/addgroup . On my box addgroup is a perl script that prompts for various options (interactively) before invoking the groupadd command. groupadd is usually preferable for scripting (say, if you wan't to create users in batch), whereas addgroup is more user friendly (especially if you are unfamiliar with all the options and flags). Of course addgroup also takes many options via the command when you invoke it, but it is primarily intended as an interactive script. Interestingly on my box addgroup is a symlink to adduser , the script checks the name it was invoked under and performs different actions accordingly. groupadd is more preferable for better cross-linux and sometimes cross-unix systems compatibility. addg

Calculating Coordinates Given A Bearing And A Distance

Answer : It seems like these are the issues in your code: You need to convert lat1 and lon1 to radians before calling your function. You may be scaling radialDistance incorrectly. Testing a floating-point number for equality is dangerous. Two numbers that are equal after exact arithmetic might not be exactly equal after floating-point arithmetic. Thus abs(x-y) < threshold is safer than x == y for testing two floating-point numbers x and y for equality. I think you want to convert lat and lon from radians to degrees. Here is my implementation of your code in Python: #!/usr/bin/env python from math import asin,cos,pi,sin rEarth = 6371.01 # Earth's average radius in km epsilon = 0.000001 # threshold for floating-point equality def deg2rad(angle): return angle*pi/180 def rad2deg(angle): return angle*180/pi def pointRadialDistance(lat1, lon1, bearing, distance): """ Return final coordinates (lat2,lon2) [in degrees] given

Burger Menu W3schools Code Example

Example 1: burger menu css /* Link to Codepen in source for PoC */ < style > .container { background : dodgerblue ; padding : 20 px ; height : 70 px ; } #hamburger { width : 40 px ; height : 40 px ; display : block ; position : relative ; float : right ; transform : rotate ( 0 deg ) ; transition : .5 s ease-in-out ; cursor : pointer ; } #hamburger span { display : block ; position : absolute ; height : 4 px ; width : 100 % ; background : white ; border-radius : 9 px ; opacity : 1 ; left : 0 ; transform : rotate ( 0 deg ) ; transition : .25 s ease-in-out ; } #hamburger span :nth-child ( 1 ) { top : 0 px ; } #hamburger span :nth-child ( 2 ) { top : 12 px ; } #hamburger span :nth-child ( 3 ) { top : 24 px ; } #hamburger .open span :nth-child ( 1 ) { top : 14 px ; transform : rotate ( 135 deg ) ; } #hamburger .open span :nth-child ( 2 ) { opa

Checkstyle : Always Receive File Contains Tab Characters (this Is The First Instance)

Answer : step 1 In eclipse, Preference > Java > Code Style > Formatter. Edit the Active profile.(If you don't wish to edit the built-in profile , create a new profile). Under "Active profile:" there is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy . Change the Tab Policy from Mixed to Space only & apply the changes. step 2 Back to your Eclipse Perspective, navigate via the menu bar: Source > Format Element (not "Format") and save. Run checkstyle you won't find "File Tab Character: File contains tab characters (this is the first instance)." warning anymore. To visualize the difference by enabling whitespace character that you'll find in tool bar. In eclipse, go to Preferences > General > Editors > Text Editors and check the box for "Insert spaces for tabs". Then it will indent

Android Deep Links Not Following Path Prefix

Answer : I figured it out, It seems like the data tags sort of bleed into one another, so the prefix of "/" on the data with scheme "example" was also applying to all of the schemes in the other data tags. I just had to use separate Intent filters for my custom scheme deep links and the url deep links like so: <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- must start with http://test.example.com/app --> <!-- http://test.example.com/ won't work since prefix / is in a different intent-filter --> <data android:scheme="http" android:host="test.example.com" android:pathPrefix="/app"/>

Advance Iterator For The Std::vector Std::advance VS Operator +?

Answer : Adding will only work with random access iterators. std::advance will work with all sorts of iterators. As long as you're only dealing with iterators into vectors, it makes no real difference, but std::advance keeps your code more generic (e.g. you could substitute a list for the vector , and that part would still work). For those who care, the standard describes advance and distance as follows (§24.3.4/1): Since only random access iterators provide + and - operators, the library provides two function templates advance and distance . These function templates use + and - for random access iterators (and are, therefore, constant time for them); for input, forward and bidirectional iterators they use ++ to provide linear time implementations. Also note that starting with C++11, the standard added a parameter to std::next , so you can advance by a specified amount using it (and std::prev similarly). The difference from std::advance is that it returns th

Bootstrap 4 Inline Form Code Example

Example 1: bootstrap 4 forms < form > < div class = " form-group row " > < label for = " staticEmail " class = " col-sm-2 col-form-label " > Email </ label > < div class = " col-sm-10 " > < input type = " text " readonly class = " form-control-plaintext " id = " staticEmail " value = " email@example.com " > </ div > </ div > < div class = " form-group row " > < label for = " inputPassword " class = " col-sm-2 col-form-label " > Password </ label > < div class = " col-sm-10 " > < input type = " password " class = " form-control " id = " inputPassword " placeholder = " Password " > </ div > </ div > </ form > Example 2: bootstrap forms < form > <