-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
java/Index.class | ||
csharp/index.exe | ||
typescript-fetch/index.js |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
PUSH_URL="https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
INTERVAL=60 | ||
|
||
while true; do | ||
curl -s -o /dev/null $PUSH_URL | ||
echo "Pushed!" | ||
sleep $INTERVAL | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Net; | ||
using System.Threading; | ||
|
||
/** | ||
* Compile: C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe index.cs | ||
* Run: index.exe | ||
*/ | ||
class Index | ||
{ | ||
const string PushURL = "https://example.com/api/push/key?status=up&msg=OK&ping="; | ||
const int Interval = 60; | ||
|
||
static void Main(string[] args) | ||
{ | ||
while (true) | ||
{ | ||
WebClient client = new WebClient(); | ||
client.DownloadString(PushURL); | ||
Console.WriteLine("Pushed!"); | ||
Thread.Sleep(Interval * 1000); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
func main() { | ||
const PushURL = "https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
const Interval = 60 | ||
|
||
for { | ||
_, err := http.Get(PushURL) | ||
if err == nil { | ||
fmt.Println("Pushed!") | ||
} | ||
time.Sleep(Interval * time.Second) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
/** | ||
* Compile: javac index.java | ||
* Run: java Index | ||
*/ | ||
class Index { | ||
|
||
public static final String PUSH_URL = "https://example.com/api/push/key?status=up&msg=OK&ping="; | ||
public static final int INTERVAL = 60; | ||
|
||
public static void main(String[] args) { | ||
while (true) { | ||
try { | ||
URL url = new URL(PUSH_URL); | ||
HttpURLConnection con = (HttpURLConnection) url.openConnection(); | ||
con.setRequestMethod("GET"); | ||
con.getResponseCode(); | ||
con.disconnect(); | ||
System.out.println("Pushed!"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
try { | ||
Thread.sleep(INTERVAL * 1000); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const pushURL = "https://example.com/api/push/key?status=up&msg=OK&ping="; | ||
const interval = 60; | ||
|
||
const push = async () => { | ||
await fetch(pushURL); | ||
console.log("Pushed!"); | ||
}; | ||
|
||
push(); | ||
setInterval(push, interval * 1000); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"scripts": { | ||
"start": "node index.js" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
const PUSH_URL = "https://example.com/api/push/key?status=up&msg=OK&ping="; | ||
const interval = 60; | ||
|
||
while (true) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, PUSH_URL); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_exec($ch); | ||
curl_close($ch); | ||
echo "Pushed!\n"; | ||
sleep(interval); | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$pushURL = "https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
$interval = 60 | ||
|
||
while ($true) { | ||
$res = Invoke-WebRequest -Uri $pushURL | ||
Write-Host "Pushed!" | ||
Start-Sleep -Seconds $interval | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import urllib.request | ||
import time | ||
|
||
push_url = "https://example.com/api/push/key?status=up&msg=OK&ping=" | ||
interval = 60 | ||
|
||
while True: | ||
urllib.request.urlopen(push_url) | ||
print("Pushed!\n") | ||
time.sleep(interval) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
Node.js (ts-node) | ||
|
||
```bash | ||
ts-node index.ts | ||
``` | ||
|
||
Deno | ||
|
||
```bash | ||
deno run --allow-net index.ts | ||
``` | ||
|
||
Bun.js | ||
|
||
```bash | ||
bun index.ts | ||
``` | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const pushURL : string = "https://example.com/api/push/key?status=up&msg=OK&ping="; | ||
const interval : number = 60; | ||
|
||
const push = async () => { | ||
await fetch(pushURL); | ||
console.log("Pushed!"); | ||
}; | ||
|
||
push(); | ||
setInterval(push, interval * 1000); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"scripts": { | ||
"ts-node": "ts-node index.ts", | ||
"deno": "deno run --allow-net index.ts", | ||
"bun": "bun index.ts" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.6.0", | ||
"ts-node": "^10.9.1", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2" | ||
} | ||
} |