The document appears to be a series of tips for writing clean, readable code in Groovy. Some of the key points mentioned include:
1. Write readable code and comment any tricks or non-obvious parts of the code.
2. Be aware that some clever code may actually be a bug.
3. Use static code analysis tools like IntelliJ IDEA to inspect code quality.
4. Refer to documentation when unsure rather than relying on tricks.
5. Avoid writing code in an overly clever or obfuscated way.
Помните легендарные Java Puzzlers? Да-да, те самые, с Джошом Блохом и Нилом Гафтером? Ну, по которым ещё книжку написали? Так вот, в Groovy всё ещё веселее.
В смысле — задачки ещё более странные, и ответы ещё более поразительные. Этот доклад для вас, Groovy-разработчики, мы покажем вам настоящие, большие и красивые подводные камни! И для вас, Java-разработчики, потому что таких вещей на Java-подобном синтакисе вы точно никогда не видели! И для вас, PHP-разработчики… хотя, нет, не для вас :)
Всем точно будет весело — ваши ведущие Женя и Барух будут зажигать, шутить, спорить, бросаться футболками в публику, и самое главное — заставят вас офигевать от Groovy.
Python là ngôn ngữ lập trình đơn giản và đang càng này càng trở lên phổ biến. Bài giảng này cung cấp cách tiếp cận đơn giản dễ hiểu với python một cách dễ dàng nhất
An Elephant of a Different Colour: HackVic Metcalfe
Slides from my GTA-PHP Meetup talk about Hack which is the Facebook version of the PHP programming language which runs under their HHVM runtime environment for PHP. The focus of my talk was the language improvements that the Facebook team has added to PHP.
There's a lot of information in the presenter's notes, so if you're interested in Hack scroll down to see the extras.
Помните легендарные Java Puzzlers? Да-да, те самые, с Джошом Блохом и Нилом Гафтером? Ну, по которым ещё книжку написали? Так вот, в Groovy всё ещё веселее.
В смысле — задачки ещё более странные, и ответы ещё более поразительные. Этот доклад для вас, Groovy-разработчики, мы покажем вам настоящие, большие и красивые подводные камни! И для вас, Java-разработчики, потому что таких вещей на Java-подобном синтакисе вы точно никогда не видели! И для вас, PHP-разработчики… хотя, нет, не для вас :)
Всем точно будет весело — ваши ведущие Женя и Барух будут зажигать, шутить, спорить, бросаться футболками в публику, и самое главное — заставят вас офигевать от Groovy.
Python là ngôn ngữ lập trình đơn giản và đang càng này càng trở lên phổ biến. Bài giảng này cung cấp cách tiếp cận đơn giản dễ hiểu với python một cách dễ dàng nhất
An Elephant of a Different Colour: HackVic Metcalfe
Slides from my GTA-PHP Meetup talk about Hack which is the Facebook version of the PHP programming language which runs under their HHVM runtime environment for PHP. The focus of my talk was the language improvements that the Facebook team has added to PHP.
There's a lot of information in the presenter's notes, so if you're interested in Hack scroll down to see the extras.
En esta charla veremos con detalle algunas de las construcciones más pythonicas y las posibilidades de expresar de forma clara, concisa y elegante cosas que en otros lenguajes nos obligarían a dar muchos rodeos.
A veces es fácil olvidar algunos recursos como que una función puede devolver varios valores, cómo manipular listas y diccionarios de forma sencilla, contextos, generadores... En esta charla veremos de forma entretenida y práctica cómo mejorar nuestro nivel de Python "nativo".
Simply Business is starting to look into new tools to improve some of our mission-critical systems. There is one application, which would hugely benefit from the concurrency and fault tolerance model offered by languages like Elixir.
To increase awareness and gauge interest in the technology, we will have a bootcamp dedicated to giving us more insights into how to build and architect applications using Elixir and OTP.
It is meant to aim for slightly more advanced concepts, so in order to prepare rest of the team to be able to read the code and have some basic understanding of constructs and tooling - we have organised a LevelUP session, to talk exactly about that...
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
Some techniques from the heady world of Functional Programming implemented in idiomatic Perl using various techniques: closures, iterators, Devel::Declare, and some distilled evil. New version now with monads! (As presented at http://conferences.yapceurope.org/lpw2008/ )
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
All new material, this time about one of the fundamental functional datastructures, the Linked List, and the overview of an implementation in Moosey Perl.
This covers some of the same material as https://github.com/osfameron/pure-fp-book but perhaps with more explanation (and covering much less material - it was only a 20 minute talk)
En esta charla veremos con detalle algunas de las construcciones más pythonicas y las posibilidades de expresar de forma clara, concisa y elegante cosas que en otros lenguajes nos obligarían a dar muchos rodeos.
A veces es fácil olvidar algunos recursos como que una función puede devolver varios valores, cómo manipular listas y diccionarios de forma sencilla, contextos, generadores... En esta charla veremos de forma entretenida y práctica cómo mejorar nuestro nivel de Python "nativo".
Simply Business is starting to look into new tools to improve some of our mission-critical systems. There is one application, which would hugely benefit from the concurrency and fault tolerance model offered by languages like Elixir.
To increase awareness and gauge interest in the technology, we will have a bootcamp dedicated to giving us more insights into how to build and architect applications using Elixir and OTP.
It is meant to aim for slightly more advanced concepts, so in order to prepare rest of the team to be able to read the code and have some basic understanding of constructs and tooling - we have organised a LevelUP session, to talk exactly about that...
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
Some techniques from the heady world of Functional Programming implemented in idiomatic Perl using various techniques: closures, iterators, Devel::Declare, and some distilled evil. New version now with monads! (As presented at http://conferences.yapceurope.org/lpw2008/ )
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
All new material, this time about one of the fundamental functional datastructures, the Linked List, and the overview of an implementation in Moosey Perl.
This covers some of the same material as https://github.com/osfameron/pure-fp-book but perhaps with more explanation (and covering much less material - it was only a 20 minute talk)
The groovy puzzlers (as Presented at Gr8Conf US 2014)GroovyPuzzlers
Remember the epic Java Puzzlers? Here’s the Groovy version, and we have some neat ones! Even though we are totally a Grails shop here at JFrog, some of these had us scratching our heads for days trying to figure them out.
And there is more! Contributions from the truly Groovy senseis, including @glaforge, @aalmiray, @tim_yates, @kenkousen make this talk an unforgettable journey to Groovy's O_O.
In this talk you’ll have the expected dose of fun and enlightenment hearing about our mistakes and failures, great and small, in hard core Groovy/Grails development.
Implement the following sorting algorithms Bubble Sort Insertion S.pdfkesav24
Implement the following sorting algorithms: Bubble Sort Insertion Sort. Selection Sort.
Merge Sort. Heap Sort. Quick Sort. For each of the above algorithms, measure the execution
time based on input sizes n, n + 10(i), n + 20(i), n + 30(i), .. ., n + 100(i) for n = 50000 and i =
100. Let the array to be sorted be randomly initialized. Use the same machine to measure all the
algorithms. Plot a graph to compare the execution times you collected in part(2).
Solution
This code wil create a graph for each plots comparing time for different sorting methods and also
save those plots in the current directory.
from random import shuffle
from time import time
import numpy as np
import matplotlib.pyplot as plt
def bubblesort(arr):
for i in range(len(arr)):
for k in range(len(arr)-1, i, -1):
if (arr[k] < arr[k-1]):
tmp = arr[k]
arr[k] = arr[k-1]
arr[k-1] = tmp
return arr
def selectionsort(arr):
for fillslot in range(len(arr)-1,0,-1):
positionOfMax=0
for location in range(1,fillslot+1):
if arr[location]>arr[positionOfMax]:
positionOfMax = location
temp = arr[fillslot]
arr[fillslot] = arr[positionOfMax]
arr[positionOfMax] = temp
return arr
def insertionsort(arr):
for i in range( 1, len( arr ) ):
tmp = arr[i]
k = i
while k > 0 and tmp < arr[k - 1]:
arr[k] = arr[k-1]
k -= 1
arr[k] = tmp
return arr
# def mergesort(arr):
#
# if len(arr)>1:
# mid = len(arr)//2
# lefthalf = arr[:mid]
# righthalf = arr[mid:]
#
# mergesort(lefthalf)
# mergesort(righthalf)
#
# i=0
# j=0
# k=0
# while i < len(lefthalf) and j < len(righthalf):
# if lefthalf[i] < righthalf[j]:
# arr[k]=lefthalf[i]
# i=i+1
# else:
# arr[k]=righthalf[j]
# j=j+1
# k=k+1
#
# while i < len(lefthalf):
# arr[k]=lefthalf[i]
# i=i+1
# k=k+1
#
# while j < len(righthalf):
# arr[k]=righthalf[j]
# j=j+1
# k=k+1
#
# return arr
def mergesort(x):
result = []
if len(x) < 2:
return x
mid = int(len(x)/2)
y = mergesort(x[:mid])
z = mergesort(x[mid:])
i = 0
j = 0
while i < len(y) and j < len(z):
if y[i] > z[j]:
result.append(z[j])
j += 1
else:
result.append(y[i])
i += 1
result += y[i:]
result += z[j:]
return result
def quicksort(arr):
less = []
equal = []
greater = []
if len(arr) > 1:
pivot = arr[0]
for x in arr:
if x < pivot:
less.append(x)
if x == pivot:
equal.append(x)
if x > pivot:
greater.append(x)
return quicksort(less)+equal+quicksort(greater) # Just use the + operator to join lists
else:
return arr
#### Heap sort
def heapsort(arr): #convert arr to heap
length = len(arr) - 1
leastParent = length / 2
for i in range(leastParent, -1, -1):
moveDown(arr, i, length)
# flatten heap into sorted array
for i in range(length, 0, -1):
if arr[0] > arr[i]:
swap(arr, 0, i)
moveDown(arr, 0, i - 1)
def moveDown(arr, first, last):
largest = 2 * first + 1
while largest <= last: #right child exists and is larger than left child
if (largest < last) and(arr[largest] < arr[largest + 1]):
largest += 1
# right child is larger than parent
if arr[largest] > arr[first]:
swap(arr, largest, first)# move down to largest child
first = largest
lar.
Slides from my PyCon 2011 talk, "Exhibition of Atrocity," a confessional of my sins against the Python programming language.
Abstract: http://us.pycon.org/2011/schedule/presentations/138/
Video: http://www.pycon.tv/#/video/49
Conheça um pouco mais sobre Perl 6, uma linguagem de programação moderna, poderosa e robusta que permitirá que você escreva código de forma ágil e eficiente.
Have you ever wondered how search works while visiting an e-commerce site, internal website, or searching through other types of online resources? Look no further than this informative session on the ways that taxonomies help end-users navigate the internet! Hear from taxonomists and other information professionals who have first-hand experience creating and working with taxonomies that aid in navigation, search, and discovery across a range of disciplines.
0x01 - Newton's Third Law: Static vs. Dynamic AbusersOWASP Beja
f you offer a service on the web, odds are that someone will abuse it. Be it an API, a SaaS, a PaaS, or even a static website, someone somewhere will try to figure out a way to use it to their own needs. In this talk we'll compare measures that are effective against static attackers and how to battle a dynamic attacker who adapts to your counter-measures.
About the Speaker
===============
Diogo Sousa, Engineering Manager @ Canonical
An opinionated individual with an interest in cryptography and its intersection with secure software development.
Acorn Recovery: Restore IT infra within minutesIP ServerOne
Introducing Acorn Recovery as a Service, a simple, fast, and secure managed disaster recovery (DRaaS) by IP ServerOne. A DR solution that helps restore your IT infra within minutes.
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Orkestra
UIIN Conference, Madrid, 27-29 May 2024
James Wilson, Orkestra and Deusto Business School
Emily Wise, Lund University
Madeline Smith, The Glasgow School of Art
This presentation by Morris Kleiner (University of Minnesota), was made during the discussion “Competition and Regulation in Professions and Occupations” held at the Working Party No. 2 on Competition and Regulation on 10 June 2024. More papers and presentations on the topic can be found out at oe.cd/crps.
This presentation was uploaded with the author’s consent.
98. List<Long> list = [1,2,3]
def now = new Date()
list << now
println list
99. List<Long> list = [1,2,3]
def now = new Date()
list << now
println list
100.
101.
102.
103.
104. List<Long> list = [1,2,3]
def now = new Date()
list << now
list << 'foo'
println list*.class.name
[java.lang.Long, java.lang.Long,
java.lang.Long, java.util.Date,
java.lang.String]
116. class Invite {
int attending = 1
}
def invite = new Invite()
def attendees = (invite.attending) +1
println attendees
Это Андрей
Это Джигурда
117. class Invite {
int attending = 1
}
def invite = new Invite()
def attendees = (invite.attending) +1
println attendees
118.
119.
120.
121.
122.
123. def attendees = (new Invite().attending) + 1
println attendees
124. def invite = new Invite()
def attendees = invite.attending +1
Как убрать скобки?!
125. def invite = new Invite()
def attendees = ((invite.attending)) +1
Наоборот добавить.
Скобки никогда нельзя
убирать!
126.
127. class MrHyde {
def me() {
return this
}
}
class DrJekyll {
}
DrJekyll.mixin MrHyde
def drJekyll = new DrJekyll().me() as DrJekyll
def mrHide = new DrJekyll().me()
println "$drJekyll and $mrHide, are they the
same? ${(drJekyll.class).equals(mrHide.class)}"
128. class MrHyde {
def me() {
return this
}
}
class DrJekyll {
}
DrJekyll.mixin MrHyde
def drJekyll = new DrJekyll().me() as DrJekyll
def mrHide = new DrJekyll().me()
println "$drJekyll and $mrHide, are they the same?
${(drJekyll.class).equals(mrHide.class)}"
129.
130.
131.
132.
133.
134. def x = int
println x
if ((x = long)) {
println x
}
if (x = boolean ) {
println x
}
135. def x = int
println x
if ((x = long)) {
println x
}
if (x = boolean ) {
println x
}
136.
137.
138.
139.
140. class VanHalen {
public static jump() {
"Here are the ${lyrics()}"
}
def methodMissing(String name, def args) {
'lyrics'
}
}
println VanHalen.jump()
141. class VanHalen {
public static jump() {
"Here are the ${lyrics()}"
}
def methodMissing(String name, def args) {
'lyrics'
}
}
println VanHalen.jump()
142.
143.
144.
145.
146. class VanHalen {
public static jump() {
"Here are the ${lyrics()}"
}
static $static_methodMissing(String name, def args) {
'lyrics'
}
}
println VanHalen.jump()
147. class VanHalen {
public jump() {
"Here are the ${lyrics()}"
}
def methodMissing(String name, def args) {
'lyrics'
}
}
println new VanHalen().jump()
155. 1. Пишите читабельный код
2. Комментируйте все трюки
3. Иногда это баг
4. Пользуйте static code
analysis - intellij IDEA!
5. Rtfm
6. Don’t code like my brother
Editor's Notes
CURRENT – FRED
NEXT - FRED
List<Integer> list = [56, '9', 74,23,25,20]def max = list.max { item -> (item < 50) ? item : null}println maxЭто ищет максимальный элемент в листе из тех, что меньше 50