Skip to content

Instantly share code, notes, and snippets.

View javascripter's full-sized avatar

javascripter

View GitHub Profile
diff --git a/node_modules/react-native-star-io10/src/Error.ts b/node_modules/react-native-star-io10/src/Error.ts
new file mode 100644
index 0000000..c9bc58a
--- /dev/null
+++ b/node_modules/react-native-star-io10/src/Error.ts
@@ -0,0 +1,4 @@
+// https://github.com/star-micronics/react-native-star-io10/issues/15
+export interface Error extends globalThis.Error {
+ code: string
+}
@javascripter
javascripter / migrate-redux-saga.ts
Last active February 25, 2021 21:57
redux-saga to typed-redux-saga
/*
Description:
This script converts `yield call()` to `yield* call()` syntax and 'redux-saga/effects' to 'typed-redux-saga'
Make sure to commit your files first before you run the below script!
Usage:
npx jscodeshift --parser tsx -t ./migrate-redux-saga.ts ./sagas/**\/*.ts
Before:
#include <stdio.h>
#include <string.h>
int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;
@javascripter
javascripter / gist:d376c9a4f22a947c5ff8
Created May 16, 2014 12:45
a step by step execution with generators
function* gcd(a, b) {
[a, b]
if (a < b) {
var t = a;
a = b;
b = t;
}
do {
r = a % b;
@javascripter
javascripter / gps_exploit.js
Last active August 19, 2021 12:36
ChatPadでGPS距離から住所を特定するexploit(修正済み)
/* GPS距離から住所を特定するexploit
* 作成: javascripter
* 3点から座標を割り出す手法のアドバイス: qnighy
*/
// メッセージ表示の際に呼ばれるaddChatLog関数をフックする
var _addChatLog = addChatLog;
addChatLog = function (kind, msg) {
if (kind == 4) { // 距離通知のメッセージ
var distance = msg.match(/(\d+)/); // km単位での距離
#include <stdio.h>
/* http://d.hatena.ne.jp/Cherenkov/20100827/p1 のビット演算的解法 */
typedef unsigned char uchar;
void putbits(uchar n) { /* 二進表現で出力 */
uchar i;
for (i = 128; i; i >>= 1) {
putchar(n & i ? '1' : '0');
#include <stdio.h>
int main(void) {
int x, y;
for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {
printf("%d x %d = %d\n", x, y, x * y);
}
}
#include <stdio.h>
long long int isqrt(long long int n) {
int i;
for (i = 1; n > 0; i++) {
n -= i * 2 + 1;
}
return i - 1;
}
#include <stdio.h>
/* Project Euler - Problem 1 */
int prob() {
int i;
int total = 0;
for (i = 1; i < 1000; i++) {
if (i % 3 == 0 ||
i % 5 == 0) {