This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$name = 'dog'; | |
$value = match ($name) { | |
'dog' => 1, | |
'cat' => 2, | |
'horse' => 3, | |
default => throw new \Exception, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On client page | |
```html | |
<re-widget type="youtube" src="https://www.youtube.com/embed/TwAFQZLK79A"></re-widget> | |
<script> | |
(function (fn) { | |
var d = document, s = d.createElement('script'); | |
s.onload = fn; d.head.appendChild(s); s.src = 'embed.js'; | |
})(function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2017-12-21T00:08:27.138Z","extensionVersion":"v2.8.7"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPalindrome (str) { | |
str = str.replace(/[^a-zA-Z]/g, '').toLowerCase() | |
var len = Math.floor(str.length / 2) | |
return (str.substring(0, len) === str.substring(len + 1).split('').reverse().join('')) | |
} | |
console.log(isPalindrome('A dog! A panic in a pagoda!')) // true | |
console.log(isPalindrome('Able was I ere I saw Elba.')) // true | |
console.log(isPalindrome('not a palindrome')) // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Pure CSS Star Rating Widget</h1> | |
<fieldset class="rating"> | |
<input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label> | |
<input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label> | |
<input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label> | |
<input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label> | |
<input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label> | |
<input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label> | |
<input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponent { | |
render () { | |
return ( | |
<h1>My Component</h1> | |
) | |
} | |
} | |
var HelloWorld = function(props) { | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"encoding/json" | |
) | |
type Person struct { | |
ID int `json:"id"` | |
Firstname string `json:"firstname"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | |
w.Write([]byte("Hello World")) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
mySlice := []string{"One", "Two", "Three"} | |
for index, item := range mySlice { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
window.onscroll = scroll; | |
function scroll () { | |
var scrollTop = window.pageYOffset; | |
console.log(scrollTop); | |
if( scrollTop > 363 ){ | |
document.getElementById('summary').style.top="20px"; | |
document.getElementById('summary').style.position="fixed"; | |
} | |
else |
NewerOlder