Skip to content

Instantly share code, notes, and snippets.

@Entity
public class Project {
@GeneratedValue
@Id
private int id;
@Column
private String name;
public int getId() {
<?php
$source_url = 'http://blog.mloza.pl';
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url); $xml = simplexml_load_string($xml);
$shares = $xml->link_stat->share_count; // Liczba share
$likes = $xml->link_stat->like_count; // Liczba like
$comments = $xml->link_stat->comment_count; // Liczba komentarzy
$total = $xml->link_stat->total_count; // Sumarycznie
?>
@mloza
mloza / append-update-archive.sh
Last active October 9, 2019 17:22
Tar: Pakowanie i rozpakowywanie plików z poziomu konsoli, kod do postu https://blog.mloza.pl/pakowanie-i-rozpakowywanie-plikow-z-poziomu-konsoli
tar rjvf nazwa_archiwum.tar plik_do_dodania
tar ujvf nazwa_archiwum.tar.bz2 katalog/
@mloza
mloza / new-switch-2.java
Last active October 24, 2019 06:28
Przykłady wykorzystane w poście na temat nowych funkcji w Javie 13 dostępnego pod adresem:
int numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
};
public class TextBlocksConcatenation {
public static void main(String[] args) {
String title = "Hello title";
String header = "Hello header";
System.out.println("""
<html>
<head>
<title>""" + title + """
</title>
@mloza
mloza / PatternMatching.java
Last active November 3, 2019 17:11
Przykłady do wpisu o nowej składni switch w Javie 13
String formatted =
switch (obj) {
case Integer i -> String.format("int %d", i);
case Byte b -> String.format("byte %d", b);
case Long l -> String.format("long %d", l);
case Double d -> String.format("double %f", d);
case String s -> String.format("String %s, s);
default -> String.format("Object %s", obj);
};
#!/bin/bash
if [ -z "${CODEBUILD_RESOLVED_SOURCE_VERSION:-}" ]; then
{
echo "Error: CODEBUILD_RESOLVED_SOURCE_VERSION is not set"
} >&2
exit 1
else
echo "Resolved hash: ${CODEBUILD_RESOLVED_SOURCE_VERSION}"
fi
@mloza
mloza / Main.java
Last active December 1, 2019 19:28
@EnableAutoConfiguration
@ComponentScan
@EnableJpaRepositories(basePackageClasses = TaskRepository.class)
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
@Service
public class HelloService {
public String getHello() {
return "World";
}
}
@mloza
mloza / Main.java
Last active December 13, 2019 14:04
@SpringBootApplication
@Controller
public class Main {
@RequestMapping("/")
@ResponseBody
public String mainPage() {
return "Hello World!";
}