Skip to content

Instantly share code, notes, and snippets.

Avatar

javascripter

View GitHub Profile
View react-native-star-io10+1.0.0.patch
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 Feb 25, 2021
redux-saga to typed-redux-saga
View migrate-redux-saga.ts
/*
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:
View gist:b82da7318364a04ec31d
#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
a step by step execution with generators
View gist:d376c9a4f22a947c5ff8
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 Aug 19, 2021
ChatPadでGPS距離から住所を特定するexploit(修正済み)
View gps_exploit.js
/* GPS距離から住所を特定するexploit
* 作成: javascripter
* 3点から座標を割り出す手法のアドバイス: qnighy
*/
// メッセージ表示の際に呼ばれるaddChatLog関数をフックする
var _addChatLog = addChatLog;
addChatLog = function (kind, msg) {
if (kind == 4) { // 距離通知のメッセージ
var distance = msg.match(/(\d+)/); // km単位での距離
View gist:554607
#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');
View 正しい.c
#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);
}
}
View prob3.c
#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;
}
View prob1.c
#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) {